Skip to content
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

polyfilling promise using core-js-pure fails after zone.js is loaded, but works with core-js. #1386

Open
JayaKrishnaNamburu opened this issue Dec 26, 2024 · 0 comments

Comments

@JayaKrishnaNamburu
Copy link

I have a use-case, where an app is loading [email protected] which patches Promise in the browser. So, even if the browser natively supports Promise.allSettled. zone.js patches it by removing the support. So, the embed app tries to load it's own polyfill using core-js. I see, recently there is an issue reported that loading core.js along side with zone.js is breaking #953. And it's been fixed 9125de6 and released in 3.15 https://github.com/zloirock/core-js/releases/tag/v3.15.2.

Well, the fix seems to work only when the package is imported via core-js and not using core-js-pure. Here is an example reproduction. I am using a older version of zone.js in the example so it patches Promise and makes allSettled undefined.

import "zone.js";
import "core-js/modules/es.promise.all-settled";

console.log(Promise.toString());
console.log(Promise.allSettled);
console.log(window["__core-js_shared__"].versions);

https://codesandbox.io/p/devbox/8dv8tz?file=%2Fsrc%2Fmain.ts%3A6%2C49
Screenshot 2024-12-26 at 2 27 54 PM

import "zone.js";
import "core-js-pure/stable/promise/all-settled";

console.log(Promise.toString());
console.log(Promise.allSettled);
console.log(window["__core-js_shared__"].versions);

https://codesandbox.io/p/devbox/bitter-sunset-forked-h9q5fg?workspaceId=ws_UbAu3TZnxbmnTtM7Ec3eoR
Screenshot 2024-12-26 at 2 27 12 PM

I looked into fixing the same, but seems the project structure changed quite a bit under core-js-pure and the plans for next. let me know how can i help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant