Skip to content

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

Open
@JayaKrishnaNamburu

Description

@JayaKrishnaNamburu

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions