Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fix(promise): fix #891, sometimes NativePromise will not ready, and reduce zone.js size #916

Merged
merged 1 commit into from
Oct 3, 2017

Conversation

JiaLiPassion
Copy link
Collaborator

fix #891

  1. sometimes NativePromise will not be fully ready when override global.Promise, we should add check about it.
  2. now by default, typescript 2.3 will compile iterable and spread operator with new polyfill code and will make dist/zone.js bigger, and we don't really have to use iterable and spread, so we use simple loop to reduce the zone.js size.

@josephliccini
Copy link

josephliccini commented Sep 28, 2017

@JiaLiPassion just so I understand this a little better, the core-js/es6/promise will:

Lazy load its prototype

can you elaborate a little more? Thanks!

lib/zone.ts Outdated
@@ -1320,7 +1320,11 @@ const Zone: ZoneType = (function(global: any) {
patchOnProperties: noop,
patchMethod: () => noop,
setNativePromise: (NativePromise: any) => {
nativeMicroTaskQueuePromise = NativePromise.resolve(0);
// sometimes NativePromise lazy load it's prototype

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's => its (typo) :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I will update the comment.

@JiaLiPassion
Copy link
Collaborator Author

@josephliccini , sure, in core-js es6.promise, the initialization of ES6 Promise is

  1. the Promise constructor was created, https://github.com/zloirock/core-js/blob/master/modules/es6.promise.js#L166
  2. override global.Promise
    https://github.com/zloirock/core-js/blob/master/modules/es6.promise.js#L216
  3. prepare Promise.resove static method.
    https://github.com/zloirock/core-js/blob/master/modules/es6.promise.js#L222

So this will cause the error.

@josephliccini
Copy link

Got it. Thank you!!

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

Successfully merging this pull request may close these issues.

es6-promise overwrites zone.js
4 participants