-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use getters to define live export bindings refresh #35967
Changes from 9 commits
a8d6c2b
27941d0
0b2cf9b
96101aa
3ca0f40
2002062
48dc607
4f24ad3
8935d49
19bb023
ca45516
deb3aeb
3fa1d0f
c5c8825
da8b58a
8c2762e
2e857dc
6776f4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,18 @@ exports.x = jquery_1.x; | |
//// [reExportAll.js] | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
for (var p in m) b(p); | ||
function b(p) { | ||
if (!exports.hasOwnProperty(p)) | ||
Object.create | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any chance you can update this for this feedback? #33587 (comment)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could, but it'd double the helper size. In the case of var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) b(k);
result["default"] = mod;
return result;
function b(p) {
if (Object.hasOwnProperty.call(mod, p))
Object.create
? Object.defineProperty(result, p, {
enumerable: true,
get: function() {
return mod[p];
}
})
: (result[p] = mod[p]);
}
}; to var __importStar = (this && this.__importStar) || (Object.create ? (function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) b(k);
result["default"] = mod;
return result;
function b(p) {
if (Object.hasOwnProperty.call(mod, p))
Object.defineProperty(result, p, {
enumerable: true,
get: function() {
return mod[p];
}
});
}
}) : (function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) b(k);
result["default"] = mod;
return result;
function b(p) {
if (Object.hasOwnProperty.call(mod, p))
result[p] = mod[p];
}
})); (you can compress it a bit by moving the property definition into another helper (eg I think doing the (hopefully fast) check on the (executed only a few times at the top level) import/export helpers is a fair enough tradeoff to make in our default helper implementations. Really: If you have strong execution speed or size concerns, you'll be providing custom helpers that target exactly the runtime you're building for, without any runtime feature testing at all. For a point of comparison: Babel's helper checks for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, that's what I had in mind. But I guess we can improve in another PR if users ask. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also could have done this: var __importStar = (this && this.__importStar) || (function () {
var setModuleDefault = (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
setModuleDefault(result, mod);
return result;
};
})(); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or this: var __importStar = (this && this.__importStar) || (function (setModuleDefault) {
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
setModuleDefault(result, mod);
return result;
};
})(Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For For There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already do that for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also defer its value until later in case a polyfill adds |
||
? Object.defineProperty(exports, p, { | ||
enumerable: true, | ||
get: function () { | ||
return m[p]; | ||
} | ||
}) | ||
: (exports[p] = m[p]); | ||
} | ||
} | ||
exports.__esModule = true; | ||
__export(require("jquery")); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to use
Object.defineProperty
(withvalue
instead ofget
), because assignments will fail ifmod
has adefault
property