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

build: make legacy standalone bundle#1201

Merged
mhevery merged 1 commit intoangular:masterfrom
JiaLiPassion:legacy-bundle
Mar 19, 2019
Merged

build: make legacy standalone bundle#1201
mhevery merged 1 commit intoangular:masterfrom
JiaLiPassion:legacy-bundle

Conversation

@JiaLiPassion
Copy link
Copy Markdown
Collaborator

In angular cli, there is a file named es2015-polyfill.js, inside this file, all polyfill for es5 legacy browsers will be there, so with zone evergreen bundle, the most idle way to handle this is.

  1. put a zone-legacy.js inside es2015-polyfill.js.
  2. put zone-evergreen.js inside polyfill.ts.

So

  1. in es5 legacy browser, it will load zone-legacy.js + zone-evergreen.js.
  2. in modern browser, it will only load zone-evergreen.js.

Before this PR, zone-legacy.js need to be loaded after zone-evergreen.js, because the zone-legacy use a lot of common logic from zone-evergreen.js. So in this PR,

  1. zone-legacy.js is a lazy load module which will only define a factory function.
  2. When zone-evergreen.js loading, it will check whether this lazy load module exist, if exists, it will execute the zone-legacy patch logic.

@JiaLiPassion JiaLiPassion force-pushed the legacy-bundle branch 2 times, most recently from ba3a022 to d6140e1 Compare March 15, 2019 12:32
registerElementPatch(global);
});
(function(_global: any) {
_global['__zone_symbol__legacyPatch'] = function() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is it necessary to add __zone_symbol__legacyPatch to the global? Who invokes that function?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, here is the flow.

  1. loading browser-legacy.js, and register this factory function in global.
  2. loading zone-evergreen.js, and call this __zone_symbol__legacyPatch here, https://github.com/angular/zone.js/pull/1201/files#diff-75082c639aefcc47b3b8df57c8870867R23, so the legacy patch can be loaded after the common logic of zone is loaded.

@mhevery mhevery merged commit a5fe09b into angular:master Mar 19, 2019
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.

3 participants