Skip to content

Make ZoneAwarePromise spec compliant and compatible with core-js #33989

@TazmanianD

Description

@TazmanianD

🚀 feature request

Relevant Package

This feature request is for @angular/zone.js

Description

I'm not an Angular developer so I'm not in much of a position to provide details on the Angular side. I'm a developer working on a webpack application that uses core-js to provide polyfills and my application is one that other sites can embed in their application.

The core-js polyfill does some checks to determine if the system has a spec compliant Promise and if not, it will use its own setting it in the global scope. The ZoneAwarePromise does not pass the core-js checks and as a result gets overridden by core-js with the result being that the Angular application stops functioning.

Most of the initial responses to this problem is that you should load the core-js application first but in our case that is not an option since we're an external application that is loaded later as an asynchronous embedding.

There was an issue file for exactly this in the zone.js repo: angular/zone.js#783 so I'm basically recreating that issue here. That issue was just closed without any actual resolution and then the whole repo was archived when it was merged here.

There was a similar question posed in core-js: zloirock/core-js#319 that offers a suggestion for what seems like a simple change that can be made to ZoneAwarePromise that would make it compliant enough to pass the core-js checks.

The project that we were causing trouble for was using Angular 7.2.15.

Describe the solution you'd like

zloirock/core-js#319 (comment)

Describe alternatives you've considered

In our webpack application, the solution was to not import the polyfill as part of the webpack configuration but to only do it conditionally if there is no Promise at all:

if (!window.Promise) {
  require('core-js/modules/es.promise');
}

Metadata

Metadata

Assignees

Labels

area: zonesIssues related to zone.js

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions