-
Notifications
You must be signed in to change notification settings - Fork 26.3k
feat(zone.js): upgrade zone.js to angular package format(APF) #36540
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
Conversation
5d1f5bd
to
a9621aa
Compare
c31024e
to
252818c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks quite good! thanks @JiaLiPassion!
Can you please do me a favor a fix one big issue: in order not to make this a breaking change, can you please ensure that the built npm package contains dist/package.json
which redirects the tools trying to resolve zone.js/dist/zone
to the right place? essentially you need to resolver redirect fromzone.js/dist/zone
to zone.js/
.
This will ensure that all Angular CLI apps remain operational, in spite of them having the following in polyfills.ts
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
@IgorMinar , thank you for the review.
To do that, in my understanding I need to output additional bundles to
So it expect that there is a |
Nope. I know that this is tricky because it's not common to have multiple package.jsons in a single package. But that is really what I'm asking for in this case. Ommitting all the other files the package should have these two package.jsons: /package.json The first one will be used by yarn/npm and should contain all the normal fields. the second one will be used just by webpack (and other build tools) and will redirect the resolution of imports to "zone.js/dist/zone" to the new file location. Does that make sense? |
@IgorMinar , thank you for the detailed instruction, I now know how to do it, I will continue to work on this. |
Sounds great. Thanks! |
a6a3d3e
to
0d3fba6
Compare
@JiaLiPassion please rerequest a review once the PR is rebased. |
3a66cfd
to
206a347
Compare
@IgorMinar , thank you for the review, I have rebased the PR. |
I rebased this PR and force pushed because the PR was red due to being too far behind the master@HEAD. Hopefully the CI will now go green. |
Close angular#35157 In the current version of zone.js, zone.js uses it's own package format, and it is not following the rule of Angualr package format(APF), so it is not easily to be consumed by Angular CLI or other bundle tools. For example, zone.js npm package has two bundles, 1. zone.js/dist/zone.js, this is a `es5` bundle. 2. zone.js/dist/zone-evergreen.js, this is a `es2015` bundle. And Angular CLI has to add some hard-coding code to handle this case, ohttps://github.com/angular/angular-cli/blob/5376a8b1392ac7bd252782d8474161ce03a4d1cb/packages/schematics/angular/application/files/src/polyfills.ts.template#L55-L58 This PR upgrade zone.js npm package format to follow APF rule, https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#heading=h.k0mh3o8u5hx The updated points are: 1. in package.json, update all bundle related properties ``` "main": "./bundles/zone.umd.js", "module": "./fesm2015/zone.js", "es2015": "./fesm2015/zone.js", "fesm2015": "./fesm2015/zone.js", ``` 2. re-organize dist folder, for example for `zone.js` bundle, now we have ``` dist/ bundles/ zone.js // this is the es5 bundle fesm2015/ zone.js // this is the es2015 bundle (in the old version is `zone-evergreen.js`) ``` 3. have several sub-packages. 1. `zone-testing`, provide zone-testing bundles include zone.js and testing libraries 2. `zone-node`, provide zone.js implemention for NodeJS 3. `zone-mix`, provide zone.js patches for both Browser and NodeJS All those sub-packages will have their own `package.json` and the bundle will reference `bundles(es5)` and `fesm2015(es2015)`. 4. keep backward compatibility, still keep the `zone.js/dist` folder, and all bundles will be redirected to `zone.js/bundles` or `zone.js/fesm2015` folders.
Zone.js has a lot of optional bundles, such as `zone-patch-message-port`, those bundles are monkey patch for specified APIs usually for soem experimental APIs or some old APIs only available for specified platforms. Those bundles will not be loaded by default. In this commit, since we have several main `sub packages` such as `zone`, `zone-node`, `zone-testing`, I put all the optional bundles under `plugins` folders for consistency.
b4056f6
to
472df98
Compare
@IgorMinar, I just rebased again, now the CI is green, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
Reviewed-for: global-approvers
) Zone.js has a lot of optional bundles, such as `zone-patch-message-port`, those bundles are monkey patch for specified APIs usually for soem experimental APIs or some old APIs only available for specified platforms. Those bundles will not be loaded by default. In this commit, since we have several main `sub packages` such as `zone`, `zone-node`, `zone-testing`, I put all the optional bundles under `plugins` folders for consistency. PR Close #36540
…r#36540) Close angular#35157 In the current version of zone.js, zone.js uses it's own package format, and it is not following the rule of Angualr package format(APF), so it is not easily to be consumed by Angular CLI or other bundle tools. For example, zone.js npm package has two bundles, 1. zone.js/dist/zone.js, this is a `es5` bundle. 2. zone.js/dist/zone-evergreen.js, this is a `es2015` bundle. And Angular CLI has to add some hard-coding code to handle this case, ohttps://github.com/angular/angular-cli/blob/5376a8b1392ac7bd252782d8474161ce03a4d1cb/packages/schematics/angular/application/files/src/polyfills.ts.template#L55-L58 This PR upgrade zone.js npm package format to follow APF rule, https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#heading=h.k0mh3o8u5hx The updated points are: 1. in package.json, update all bundle related properties ``` "main": "./bundles/zone.umd.js", "module": "./fesm2015/zone.js", "es2015": "./fesm2015/zone.js", "fesm2015": "./fesm2015/zone.js", ``` 2. re-organize dist folder, for example for `zone.js` bundle, now we have ``` dist/ bundles/ zone.js // this is the es5 bundle fesm2015/ zone.js // this is the es2015 bundle (in the old version is `zone-evergreen.js`) ``` 3. have several sub-packages. 1. `zone-testing`, provide zone-testing bundles include zone.js and testing libraries 2. `zone-node`, provide zone.js implemention for NodeJS 3. `zone-mix`, provide zone.js patches for both Browser and NodeJS All those sub-packages will have their own `package.json` and the bundle will reference `bundles(es5)` and `fesm2015(es2015)`. 4. keep backward compatibility, still keep the `zone.js/dist` folder, and all bundles will be redirected to `zone.js/bundles` or `zone.js/fesm2015` folders. PR Close angular#36540
…ular#36540) Zone.js has a lot of optional bundles, such as `zone-patch-message-port`, those bundles are monkey patch for specified APIs usually for soem experimental APIs or some old APIs only available for specified platforms. Those bundles will not be loaded by default. In this commit, since we have several main `sub packages` such as `zone`, `zone-node`, `zone-testing`, I put all the optional bundles under `plugins` folders for consistency. PR Close angular#36540
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…r#36540) Close angular#35157 In the current version of zone.js, zone.js uses it's own package format, and it is not following the rule of Angualr package format(APF), so it is not easily to be consumed by Angular CLI or other bundle tools. For example, zone.js npm package has two bundles, 1. zone.js/dist/zone.js, this is a `es5` bundle. 2. zone.js/dist/zone-evergreen.js, this is a `es2015` bundle. And Angular CLI has to add some hard-coding code to handle this case, ohttps://github.com/angular/angular-cli/blob/5376a8b1392ac7bd252782d8474161ce03a4d1cb/packages/schematics/angular/application/files/src/polyfills.ts.template#L55-L58 This PR upgrade zone.js npm package format to follow APF rule, https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#heading=h.k0mh3o8u5hx The updated points are: 1. in package.json, update all bundle related properties ``` "main": "./bundles/zone.umd.js", "module": "./fesm2015/zone.js", "es2015": "./fesm2015/zone.js", "fesm2015": "./fesm2015/zone.js", ``` 2. re-organize dist folder, for example for `zone.js` bundle, now we have ``` dist/ bundles/ zone.js // this is the es5 bundle fesm2015/ zone.js // this is the es2015 bundle (in the old version is `zone-evergreen.js`) ``` 3. have several sub-packages. 1. `zone-testing`, provide zone-testing bundles include zone.js and testing libraries 2. `zone-node`, provide zone.js implemention for NodeJS 3. `zone-mix`, provide zone.js patches for both Browser and NodeJS All those sub-packages will have their own `package.json` and the bundle will reference `bundles(es5)` and `fesm2015(es2015)`. 4. keep backward compatibility, still keep the `zone.js/dist` folder, and all bundles will be redirected to `zone.js/bundles` or `zone.js/fesm2015` folders. PR Close angular#36540
…ular#36540) Zone.js has a lot of optional bundles, such as `zone-patch-message-port`, those bundles are monkey patch for specified APIs usually for soem experimental APIs or some old APIs only available for specified platforms. Those bundles will not be loaded by default. In this commit, since we have several main `sub packages` such as `zone`, `zone-node`, `zone-testing`, I put all the optional bundles under `plugins` folders for consistency. PR Close angular#36540
Close #35157
In the current version of zone.js, zone.js uses it's own package format, and it is not following the rule
of Angualr package format(APF), so it is not easily to be consumed by Angular CLI or other bundle tools.
For example, zone.js npm package has two bundles,
es5
bundle.es2015
bundle.And Angular CLI has to add some hard-coding code to handle this case, ohttps://github.com/angular/angular-cli/blob/5376a8b1392ac7bd252782d8474161ce03a4d1cb/packages/schematics/angular/application/files/src/polyfills.ts.template#L55-L58
This PR upgrade zone.js npm package format to follow APF rule, https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#heading=h.k0mh3o8u5hx
The updated points are:
zone.js
bundle, now we havehave several sub-packages.
zone-testing
, provide zone-testing bundles include zone.js and testing librarieszone-node
, provide zone.js implemention for NodeJSzone-mix
, provide zone.js patches for both Browser and NodeJSAll those sub-packages will have their own
package.json
and the bundle will referencebundles(es5)
andfesm2015(es2015)
.typings
property are removed frompackage.json
, instead usingfiles
property, because now we have severald.ts
files as typings.Does this PR introduce a breaking change?
All
zone.js
npm package folder and file name are changed, so we need toI created a sample repo to show the contents of the new npm package contents.
https://github.com/JiaLiPassion/zone-new-package-format/tree/master/npm_package
package.json
, https://github.com/JiaLiPassion/zone-new-package-format/blob/master/npm_package/package.jsonbundles folder
, https://github.com/JiaLiPassion/zone-new-package-format/tree/master/npm_package/bundlesfesm2015 folder
, https://github.com/JiaLiPassion/zone-new-package-format/tree/master/npm_package/bundlesnode sub package
, https://github.com/JiaLiPassion/zone-new-package-format/tree/master/npm_package/nodemix sub package
, https://github.com/JiaLiPassion/zone-new-package-format/tree/master/npm_package/mixtesting
, https://github.com/JiaLiPassion/zone-new-package-format/tree/master/npm_package/testingPlease check whether the output satisfy the requirements.
And the following up tasks will be.
angular repo
work with the new format.angular cli
for migration.import 'zone.js/dist/zone'
ofpolyfills.ts
.