-
Notifications
You must be signed in to change notification settings - Fork 18
Still have not given conclusive examples of in-the-wild sites that will break by introducing properties named global or self or window #16
Comments
What would constitute "conclusive" to you? |
(fwiw, the top-level namespace |
An example of code found by, say, scraping the Alex top 5K, where adding a property named "global" or "self" or "window" will cause web-visible breakage.
The reflective module API is not guaranteed to exist in its current form; this is not at all a good argument. |
Basically, the bar of proof here has to be as high as the one that prevented us from shipping Array.prototype.values for so long. |
That's why I chose Wouldn't sites in the Alexa top 5K be evangelizeable, and thus not apply? If any site breaks, then that imo constitutes "web visible breakage". As for |
The situation is the same: we (or in this case I) want to ship a nicely-named something that fits with existing practices. The alternative is something ugly and verbose ( |
I believe @erights had some SES-ish objections to it being a top-level property - hopefully he can clarify, since that might make this discussion moot. In the meantime, I'll keep trawling code for examples that meet your desired bar. |
@erights has a vision of namespacing "capability-granting" objects inside |
In the end, I think we'd be better served by trying to ship In fact, |
Based on the last committee consensus, only |
Node accepts breaking changes in each upgrade. For example, the change to the serialization of regexps caused some node apps to break. Similarly the change to TypedArrays to use species. It's important to show that the breakage would be widespread, e.g. use Node's cigtm mechanism on a custom build of V8 that has a global named
This confusion is already present. Formalizing what already exists does not hurt.
That was not my impression. But I'm happy to try for |
(Linking to #11) |
Some examples of using |
So let me try to explain what I think the priorities are here, partially based on discussions within the Chrome team. From highest to lowest:
Given these priorities our preferred solution is |
Just a heads up, at the moment Lodash makes the assumption that if there's free variable // Expose Lodash on the free variable `self` when available so it's globally
// accessible, even when bundled with Browserify, Webpack, etc. This prevents
// errors in cases where Lodash is loaded by a script tag in the presence of
// an AMD loader. See http://requirejs.org/docs/errors.html#mismatch for more
// details. Use `_.noConflict` to remove Lodash from the global object.
(freeSelf || {})._ = _;
// Some AMD build optimizers like r.js check for condition patterns like the following:
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
// Define as an anonymous module so, through path mapping, it can be
// referenced as the "underscore" module.
define(function() {
return _;
});
}
// Check for `exports` after `define` in case a build optimizer adds an `exports` object.
else if (freeModule) {
// Export for Node.js.
(freeModule.exports = _)._ = _;
// Export for CommonJS support.
freeExports._ = _;
}
else {
// Export to the global object.
root._ = _;
} |
Yep, it would be a breaking change, like many things are in each new Node version. |
thoughts:
|
We've decided to rename this to |
I'm still not in favor of creating an entire new top-level namespace, and a fourth way of referring to the global, until this can be conclusively shown to be web-incompatible.
The text was updated successfully, but these errors were encountered: