-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Module polyfill override project polyfill #880
Comments
Yes, this feature detection test case is problematic. I have no ideas about how to detect unhandled rejection tracking support synchronously with another way than check However, at first, your issue related to good practices of usage - you should load only one copy of the global Sure, good tooling could help to prevent problems like this. I have some ideas which could help to prevent problems like this in the next generation of tooling, but if it will be created - it will be created not soon. |
Yes, I know global single code-js is a good idea, but in some case, such as core-js loaded in some library or in some plugin, it's not uncontrolled by me. Maybe we can add a custom property to the polyfilled // core-js/modules/es.promise.js:225 // check the current NativePromise should override
if (FORCED && !PromiseConstructor.__FROM_CORE_JS__) {
PromiseConstructor = function Promise(executor) {
// ...
};
// add the tag property
PromiseConstructor.__FROM_CORE_JS__ = true;
} |
It's already here - see |
No. My core-js version is The function Promise(executor) {
anInstance(this, PromiseConstructor, PROMISE);
aFunction(executor);
Internal.call(this);
var state = getInternalState(this);
try {
executor(bind(internalResolve, this, state), bind(internalReject, this, state));
} catch (error) {
internalReject(this, state, error);
}
}; |
Interesting. |
It's fixed in 3.7.0, thank you. 😄 |
In the following case, Promise.finally will be wrongly overwritten:
In project A I imported module B, the module bundled core-js with
buildIn: usage
, then it bundle polyfill with this in builded code:In project A, I want to bundle all polyfill into one file, so I use
buildIn: entry
to bundle a singlepolyfill.js
, then in my project bundle, bundle html will be this:The polyfill.js load the right Promise, but in Edge 18, because of empty
PromiseRejectionEvent
, Promise will force override byPromiseConstructor
:It's OK now, but when run into A.js, B module bundled
core-js/modules/es.promise
, withoutes.promise.finally
, then it's broken, the varFORCED
always to be true, thePromise
will be override with the next one withoutfinally
.So is there some good idea to avoid duplicated
Promise
polyfill load?Such as add a tag to Promise polyfill, then in next polyfill running, check the tag to avoid duplicated overridden?
The text was updated successfully, but these errors were encountered: