2019-05-31 11:56:07 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2019-05-31 11:56:07 -04:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
import * as path from 'path';
|
|
|
|
import * as shx from 'shelljs';
|
|
|
|
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
function checkInSubFolder(subFolder: string, testFn: Function) {
|
|
|
|
shx.cd(subFolder);
|
|
|
|
testFn();
|
|
|
|
shx.cd('../');
|
|
|
|
}
|
|
|
|
|
2019-05-31 11:56:07 -04:00
|
|
|
describe('Zone.js npm_package', () => {
|
|
|
|
beforeEach(
|
|
|
|
() => {shx.cd(
|
|
|
|
path.dirname(require.resolve('angular/packages/zone.js/npm_package/package.json')))});
|
|
|
|
describe('misc root files', () => {
|
|
|
|
describe('README.md', () => {
|
2020-04-13 19:40:21 -04:00
|
|
|
it('should have a README.md file with basic info', () => {
|
|
|
|
expect(shx.cat('README.md')).toContain(`Zone`);
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('primary entry-point', () => {
|
|
|
|
const packageJson = 'package.json';
|
|
|
|
|
2020-04-13 19:40:21 -04:00
|
|
|
it('should have a package.json file', () => {
|
|
|
|
expect(shx.grep('"name":', packageJson)).toContain(`zone.js`);
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
|
|
|
|
it('should contain correct version number with the PLACEHOLDER string replaced', () => {
|
|
|
|
expect(shx.grep('"version":', packageJson)).toMatch(/\d+\.\d+\.\d+(?!-PLACEHOLDER)/);
|
|
|
|
});
|
|
|
|
|
2020-04-13 19:40:21 -04:00
|
|
|
it('should contain module resolution mappings', () => {
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
expect(shx.grep('"main":', packageJson)).toContain(`zone.umd.js`);
|
2020-04-13 19:40:21 -04:00
|
|
|
});
|
2020-08-26 04:12:04 -04:00
|
|
|
|
|
|
|
it('should contain typings', () => {
|
|
|
|
expect(shx.grep('"typings":', packageJson)).toContain(`./zone.d.ts`);
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
});
|
|
|
|
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
describe('check npm_package root folder', () => {
|
2019-05-31 11:56:07 -04:00
|
|
|
describe('typescript support', () => {
|
2020-08-26 04:12:04 -04:00
|
|
|
it('should have an zone.d.ts file', () => {
|
|
|
|
expect(shx.cat('zone.d.ts')).toContain('declare const');
|
|
|
|
expect(shx.cat('zone.d.ts')).toContain('interface EventTarget');
|
|
|
|
expect(shx.cat('zone.d.ts')).toContain('ZoneGlobalConfigurations');
|
2020-02-10 15:10:33 -05:00
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('closure', () => {
|
2020-04-13 19:40:21 -04:00
|
|
|
it('should contain externs', () => {
|
|
|
|
expect(shx.cat('zone_externs.js')).toContain('Externs for zone.js');
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
});
|
|
|
|
|
2020-03-10 00:44:13 -04:00
|
|
|
describe('rxjs patch', () => {
|
|
|
|
it('should not contain rxjs source', () => {
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
checkInSubFolder('./bundles', () => {
|
|
|
|
expect(shx.cat('zone-patch-rxjs.umd.js'))
|
|
|
|
.not.toContain('_enable_super_gross_mode_that_will_cause_bad_things');
|
|
|
|
});
|
|
|
|
checkInSubFolder('./fesm2015', () => {
|
|
|
|
expect(shx.cat('zone-patch-rxjs.js'))
|
|
|
|
.not.toContain('_enable_super_gross_mode_that_will_cause_bad_things');
|
|
|
|
});
|
2020-03-10 00:44:13 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-05-31 11:56:07 -04:00
|
|
|
describe('es5', () => {
|
2020-04-13 19:40:21 -04:00
|
|
|
it('zone.js(es5) should not contain es6 spread code', () => {
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
checkInSubFolder('./bundles', () => {
|
|
|
|
expect(shx.cat('zone.umd.js')).not.toContain('let value of values');
|
|
|
|
});
|
2020-04-13 19:40:21 -04:00
|
|
|
});
|
2019-07-29 19:07:43 -04:00
|
|
|
|
2020-04-13 19:40:21 -04:00
|
|
|
it('zone.js(es5) should not contain source map comment', () => {
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
checkInSubFolder('./bundles', () => {
|
|
|
|
expect(shx.cat('zone.umd.js')).not.toContain('sourceMappingURL');
|
|
|
|
});
|
2020-04-13 19:40:21 -04:00
|
|
|
});
|
fix(zone.js): fesm2015 bundle should also be strict module. (#40456)
Close #40215
`fesm2015/zone.js` is built to `esm` bundle with rollup, so the 'use strict';
statement is not generated in the bundle, even we put the 'use strict' in the src code,
rollup removes the code in the final bundle.
So if we load the `fesm2015/zone.js` as a module, such as `ng serve`, in the index.html
```
<script src="polyfills.js" type="module"></script>
```
Everything works fine, since polyfills.js is loaded as `module`, so it is always `strict`.
But in `ng test`, webpack concat the `zone.js` and loaded into the karma html. For other app and
test code, they are still `strict` since they are `module` because they have `export/import`
statement, but `zone.js` is a bundle without `export`, it is a `side effect` bundle, so after
loaded by webpack, it becomes non-strict. Which causes some issues, such as #40215,
the root cause is the `this` context should be `undefined` but treated as `Window` in `non-strict` mode.
```
Object.prototype.toString.apply(undefined);
// should be [object undefined], but it is [object Window] in non-strict mode.
// zone.js patched version of toString
Object.prototype.toString = function() {
...
// in non-strict mode, this is Window
return originalObjectPrototypeToString.call(this);
}
```
So in this commit, `'use strict';` is always added to the `esm` bundles.
PR Close #40456
2021-01-15 20:14:08 -05:00
|
|
|
|
|
|
|
it('zone.js(es5) should contain use strict', () => {
|
|
|
|
checkInSubFolder('./bundles', () => {
|
|
|
|
expect(shx.cat('zone.umd.js')).toMatch(/^\s*'use strict';/);
|
|
|
|
});
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('es2015', () => {
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
it('zone.js(es2015) should contain es6 code', () => {
|
|
|
|
checkInSubFolder('./fesm2015', () => {
|
|
|
|
expect(shx.cat('zone.js')).toContain('let value of values');
|
|
|
|
});
|
2020-04-13 19:40:21 -04:00
|
|
|
});
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
it('zone.js(es2015) should not contain source map comment', () => {
|
|
|
|
checkInSubFolder('./fesm2015', () => {
|
|
|
|
expect(shx.cat('zone.js')).not.toContain('sourceMappingURL');
|
|
|
|
});
|
2020-04-13 19:40:21 -04:00
|
|
|
});
|
fix(zone.js): fesm2015 bundle should also be strict module. (#40456)
Close #40215
`fesm2015/zone.js` is built to `esm` bundle with rollup, so the 'use strict';
statement is not generated in the bundle, even we put the 'use strict' in the src code,
rollup removes the code in the final bundle.
So if we load the `fesm2015/zone.js` as a module, such as `ng serve`, in the index.html
```
<script src="polyfills.js" type="module"></script>
```
Everything works fine, since polyfills.js is loaded as `module`, so it is always `strict`.
But in `ng test`, webpack concat the `zone.js` and loaded into the karma html. For other app and
test code, they are still `strict` since they are `module` because they have `export/import`
statement, but `zone.js` is a bundle without `export`, it is a `side effect` bundle, so after
loaded by webpack, it becomes non-strict. Which causes some issues, such as #40215,
the root cause is the `this` context should be `undefined` but treated as `Window` in `non-strict` mode.
```
Object.prototype.toString.apply(undefined);
// should be [object undefined], but it is [object Window] in non-strict mode.
// zone.js patched version of toString
Object.prototype.toString = function() {
...
// in non-strict mode, this is Window
return originalObjectPrototypeToString.call(this);
}
```
So in this commit, `'use strict';` is always added to the `esm` bundles.
PR Close #40456
2021-01-15 20:14:08 -05:00
|
|
|
it('zone.js(es2015) should contain use strict', () => {
|
|
|
|
checkInSubFolder('./fesm2015', () => {
|
|
|
|
expect(shx.cat('zone.js')).toMatch(/^\s*'use strict';/);
|
|
|
|
});
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
});
|
|
|
|
|
2020-06-09 10:12:21 -04:00
|
|
|
|
|
|
|
describe('plugins folder check', () => {
|
|
|
|
it('should contain all plugin folders in ./plugins', () => {
|
|
|
|
const expected = [
|
|
|
|
'async-test',
|
|
|
|
'async-test.min',
|
|
|
|
'fake-async-test',
|
|
|
|
'fake-async-test.min',
|
|
|
|
'jasmine-patch',
|
|
|
|
'jasmine-patch.min',
|
|
|
|
'long-stack-trace-zone',
|
|
|
|
'long-stack-trace-zone.min',
|
|
|
|
'mocha-patch',
|
|
|
|
'mocha-patch.min',
|
|
|
|
'proxy',
|
|
|
|
'proxy.min',
|
|
|
|
'sync-test',
|
|
|
|
'sync-test.min',
|
|
|
|
'task-tracking',
|
|
|
|
'task-tracking.min',
|
|
|
|
'webapis-media-query',
|
|
|
|
'webapis-media-query.min',
|
|
|
|
'webapis-notification',
|
|
|
|
'webapis-notification.min',
|
|
|
|
'webapis-rtc-peer-connection',
|
|
|
|
'webapis-rtc-peer-connection.min',
|
|
|
|
'webapis-shadydom',
|
|
|
|
'webapis-shadydom.min',
|
|
|
|
'wtf',
|
|
|
|
'wtf.min',
|
|
|
|
'zone-bluebird',
|
|
|
|
'zone-bluebird.min',
|
|
|
|
'zone-error',
|
|
|
|
'zone-error.min',
|
|
|
|
'zone-legacy',
|
|
|
|
'zone-legacy.min',
|
|
|
|
'zone-patch-canvas',
|
|
|
|
'zone-patch-canvas.min',
|
|
|
|
'zone-patch-cordova',
|
|
|
|
'zone-patch-cordova.min',
|
|
|
|
'zone-patch-electron',
|
|
|
|
'zone-patch-electron.min',
|
|
|
|
'zone-patch-fetch',
|
|
|
|
'zone-patch-fetch.min',
|
|
|
|
'zone-patch-jsonp',
|
|
|
|
'zone-patch-jsonp.min',
|
|
|
|
'zone-patch-message-port',
|
|
|
|
'zone-patch-message-port.min',
|
|
|
|
'zone-patch-promise-test',
|
|
|
|
'zone-patch-promise-test.min',
|
|
|
|
'zone-patch-resize-observer',
|
|
|
|
'zone-patch-resize-observer.min',
|
|
|
|
'zone-patch-rxjs-fake-async',
|
|
|
|
'zone-patch-rxjs-fake-async.min',
|
|
|
|
'zone-patch-rxjs',
|
|
|
|
'zone-patch-rxjs.min',
|
|
|
|
'zone-patch-socket-io',
|
|
|
|
'zone-patch-socket-io.min',
|
|
|
|
'zone-patch-user-media',
|
|
|
|
'zone-patch-user-media.min',
|
|
|
|
].sort();
|
|
|
|
|
|
|
|
checkInSubFolder('./plugins', () => {
|
|
|
|
const list = shx.ls('./').stdout.split('\n').sort().slice(1);
|
|
|
|
expect(list.length).toBe(expected.length);
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
expect(list[i]).toEqual(expected[i]);
|
|
|
|
const packageJson = shx.cat(`${list[i]}/package.json`);
|
|
|
|
const umdMinName = list[i].indexOf('.min') === -1 ?
|
|
|
|
`${list[i]}.umd` :
|
|
|
|
`${list[i].substring(0, list[i].indexOf('.min'))}.umd.min`;
|
|
|
|
expect(packageJson).toContain(`"name": "zone.js/${list[i]}"`);
|
|
|
|
expect(packageJson).toContain(`"main": "../../bundles/${umdMinName}.js"`);
|
|
|
|
expect(packageJson).toContain(`"fesm2015": "../../fesm2015/${list[i]}.js"`);
|
|
|
|
expect(packageJson).toContain(`"es2015": "../../fesm2015/${list[i]}.js"`);
|
|
|
|
expect(packageJson).toContain(`"module": "../../fesm2015/${list[i]}.js"`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
fix(zone.js): should have better backward compatibilities (#38797)
Close #38561, #38669
zone.js 0.11.1 introduces a breaking change to adpat Angular package format,
and it breaks the module loading order, before 0.11, in IE11, the `zone.js` es5
format bundle will be imported, but after 0.11, the `fesm2015` format bundle will
be imported, which causes error.
And since the only purpose of the `dist` folder of zone.js bundles is to keep backward
compatibility, in the original commit, I use package redirect to implement that, but
it is not fully backward compatible, we should keep the same dist structure as `0.10.3`.
PR Close #38797
2020-09-10 14:28:40 -04:00
|
|
|
describe('bundles file list', () => {
|
2019-05-31 11:56:07 -04:00
|
|
|
it('should contain all files', () => {
|
|
|
|
const expected = [
|
|
|
|
'async-test.js',
|
|
|
|
'async-test.min.js',
|
|
|
|
'fake-async-test.js',
|
|
|
|
'fake-async-test.min.js',
|
|
|
|
'jasmine-patch.js',
|
|
|
|
'jasmine-patch.min.js',
|
|
|
|
'long-stack-trace-zone.js',
|
|
|
|
'long-stack-trace-zone.min.js',
|
|
|
|
'mocha-patch.js',
|
|
|
|
'mocha-patch.min.js',
|
|
|
|
'proxy.js',
|
|
|
|
'proxy.min.js',
|
|
|
|
'sync-test.js',
|
|
|
|
'sync-test.min.js',
|
|
|
|
'task-tracking.js',
|
|
|
|
'task-tracking.min.js',
|
|
|
|
'webapis-media-query.js',
|
|
|
|
'webapis-media-query.min.js',
|
|
|
|
'webapis-notification.js',
|
|
|
|
'webapis-notification.min.js',
|
|
|
|
'webapis-rtc-peer-connection.js',
|
|
|
|
'webapis-rtc-peer-connection.min.js',
|
|
|
|
'webapis-shadydom.js',
|
|
|
|
'webapis-shadydom.min.js',
|
|
|
|
'wtf.js',
|
|
|
|
'wtf.min.js',
|
|
|
|
'zone-bluebird.js',
|
|
|
|
'zone-bluebird.min.js',
|
|
|
|
'zone-error.js',
|
|
|
|
'zone-error.min.js',
|
|
|
|
'zone-legacy.js',
|
|
|
|
'zone-legacy.min.js',
|
|
|
|
'zone-mix.js',
|
|
|
|
'zone-mix.min.js',
|
|
|
|
'zone-node.js',
|
|
|
|
'zone-node.min.js',
|
|
|
|
'zone-patch-canvas.js',
|
|
|
|
'zone-patch-canvas.min.js',
|
|
|
|
'zone-patch-cordova.js',
|
|
|
|
'zone-patch-cordova.min.js',
|
|
|
|
'zone-patch-electron.js',
|
|
|
|
'zone-patch-electron.min.js',
|
|
|
|
'zone-patch-fetch.js',
|
|
|
|
'zone-patch-fetch.min.js',
|
|
|
|
'zone-patch-jsonp.js',
|
|
|
|
'zone-patch-jsonp.min.js',
|
2020-03-11 19:38:37 -04:00
|
|
|
'zone-patch-message-port.js',
|
|
|
|
'zone-patch-message-port.min.js',
|
2019-05-31 11:56:07 -04:00
|
|
|
'zone-patch-promise-test.js',
|
|
|
|
'zone-patch-promise-test.min.js',
|
|
|
|
'zone-patch-resize-observer.js',
|
|
|
|
'zone-patch-resize-observer.min.js',
|
|
|
|
'zone-patch-rxjs-fake-async.js',
|
|
|
|
'zone-patch-rxjs-fake-async.min.js',
|
|
|
|
'zone-patch-rxjs.js',
|
|
|
|
'zone-patch-rxjs.min.js',
|
|
|
|
'zone-patch-socket-io.js',
|
|
|
|
'zone-patch-socket-io.min.js',
|
|
|
|
'zone-patch-user-media.js',
|
|
|
|
'zone-patch-user-media.min.js',
|
|
|
|
'zone-testing-bundle.js',
|
|
|
|
'zone-testing-bundle.min.js',
|
|
|
|
'zone-testing-node-bundle.js',
|
|
|
|
'zone-testing-node-bundle.min.js',
|
|
|
|
'zone-testing.js',
|
|
|
|
'zone-testing.min.js',
|
|
|
|
'zone.js',
|
|
|
|
'zone.min.js',
|
|
|
|
].sort();
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
checkInSubFolder('./bundles', () => {
|
|
|
|
const list = shx.ls('./').stdout.split('\n').sort().slice(1);
|
|
|
|
expect(list.length).toBe(expected.length);
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
if (expected[i].indexOf('.min.js') !== -1) {
|
|
|
|
expect(list[i]).toEqual(expected[i].replace('.min.js', '.umd.min.js'));
|
|
|
|
} else {
|
|
|
|
expect(list[i]).toEqual(expected[i].replace('.js', '.umd.js'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
checkInSubFolder('./fesm2015', () => {
|
|
|
|
const list = shx.ls('./').stdout.split('\n').sort().slice(1);
|
|
|
|
expect(list.length).toBe(expected.length);
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
expect(list[i]).toEqual(expected[i]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('backward compatible check', () => {
|
|
|
|
it('should contain all original folders in /dist', () => {
|
fix(zone.js): should have better backward compatibilities (#38797)
Close #38561, #38669
zone.js 0.11.1 introduces a breaking change to adpat Angular package format,
and it breaks the module loading order, before 0.11, in IE11, the `zone.js` es5
format bundle will be imported, but after 0.11, the `fesm2015` format bundle will
be imported, which causes error.
And since the only purpose of the `dist` folder of zone.js bundles is to keep backward
compatibility, in the original commit, I use package redirect to implement that, but
it is not fully backward compatible, we should keep the same dist structure as `0.10.3`.
PR Close #38797
2020-09-10 14:28:40 -04:00
|
|
|
const list = shx.ls('./dist').stdout.split('\n').sort().slice(1);
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
const expected = [
|
fix(zone.js): should have better backward compatibilities (#38797)
Close #38561, #38669
zone.js 0.11.1 introduces a breaking change to adpat Angular package format,
and it breaks the module loading order, before 0.11, in IE11, the `zone.js` es5
format bundle will be imported, but after 0.11, the `fesm2015` format bundle will
be imported, which causes error.
And since the only purpose of the `dist` folder of zone.js bundles is to keep backward
compatibility, in the original commit, I use package redirect to implement that, but
it is not fully backward compatible, we should keep the same dist structure as `0.10.3`.
PR Close #38797
2020-09-10 14:28:40 -04:00
|
|
|
'async-test.js',
|
|
|
|
'async-test.min.js',
|
|
|
|
'fake-async-test.js',
|
|
|
|
'fake-async-test.min.js',
|
|
|
|
'jasmine-patch.js',
|
|
|
|
'jasmine-patch.min.js',
|
|
|
|
'long-stack-trace-zone.js',
|
|
|
|
'long-stack-trace-zone.min.js',
|
|
|
|
'mocha-patch.js',
|
|
|
|
'mocha-patch.min.js',
|
|
|
|
'proxy.js',
|
|
|
|
'proxy.min.js',
|
|
|
|
'sync-test.js',
|
|
|
|
'sync-test.min.js',
|
|
|
|
'task-tracking.js',
|
|
|
|
'task-tracking.min.js',
|
|
|
|
'webapis-media-query.js',
|
|
|
|
'webapis-media-query.min.js',
|
|
|
|
'webapis-notification.js',
|
|
|
|
'webapis-notification.min.js',
|
|
|
|
'webapis-rtc-peer-connection.js',
|
|
|
|
'webapis-rtc-peer-connection.min.js',
|
|
|
|
'webapis-shadydom.js',
|
|
|
|
'webapis-shadydom.min.js',
|
|
|
|
'wtf.js',
|
|
|
|
'wtf.min.js',
|
|
|
|
'zone_externs.js',
|
|
|
|
'zone-bluebird.js',
|
|
|
|
'zone-bluebird.min.js',
|
|
|
|
'zone-error.js',
|
|
|
|
'zone-error.min.js',
|
|
|
|
'zone-evergreen.js',
|
|
|
|
'zone-evergreen.min.js',
|
|
|
|
'zone-evergreen-testing-bundle.js',
|
|
|
|
'zone-evergreen-testing-bundle.min.js',
|
|
|
|
'zone-legacy.js',
|
|
|
|
'zone-legacy.min.js',
|
|
|
|
'zone-mix.js',
|
|
|
|
'zone-mix.min.js',
|
|
|
|
'zone-node.js',
|
|
|
|
'zone-node.min.js',
|
|
|
|
'zone-patch-canvas.js',
|
|
|
|
'zone-patch-canvas.min.js',
|
|
|
|
'zone-patch-cordova.js',
|
|
|
|
'zone-patch-cordova.min.js',
|
|
|
|
'zone-patch-electron.js',
|
|
|
|
'zone-patch-electron.min.js',
|
|
|
|
'zone-patch-fetch.js',
|
|
|
|
'zone-patch-fetch.min.js',
|
|
|
|
'zone-patch-jsonp.js',
|
|
|
|
'zone-patch-jsonp.min.js',
|
|
|
|
'zone-patch-message-port.js',
|
|
|
|
'zone-patch-message-port.min.js',
|
|
|
|
'zone-patch-promise-test.js',
|
|
|
|
'zone-patch-promise-test.min.js',
|
|
|
|
'zone-patch-resize-observer.js',
|
|
|
|
'zone-patch-resize-observer.min.js',
|
|
|
|
'zone-patch-rxjs-fake-async.js',
|
|
|
|
'zone-patch-rxjs-fake-async.min.js',
|
|
|
|
'zone-patch-rxjs.js',
|
|
|
|
'zone-patch-rxjs.min.js',
|
|
|
|
'zone-patch-socket-io.js',
|
|
|
|
'zone-patch-socket-io.min.js',
|
|
|
|
'zone-patch-user-media.js',
|
|
|
|
'zone-patch-user-media.min.js',
|
|
|
|
'zone-testing-bundle.js',
|
|
|
|
'zone-testing-bundle.min.js',
|
|
|
|
'zone-testing-node-bundle.js',
|
|
|
|
'zone-testing-node-bundle.min.js',
|
|
|
|
'zone-testing.js',
|
|
|
|
'zone-testing.min.js',
|
|
|
|
'zone.js',
|
|
|
|
'zone.js.d.ts',
|
|
|
|
'zone.api.extensions.ts',
|
|
|
|
'zone.configurations.api.ts',
|
|
|
|
'zone.min.js',
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#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,
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 #36540
2020-05-16 21:53:03 -04:00
|
|
|
].sort();
|
fix(zone.js): should have better backward compatibilities (#38797)
Close #38561, #38669
zone.js 0.11.1 introduces a breaking change to adpat Angular package format,
and it breaks the module loading order, before 0.11, in IE11, the `zone.js` es5
format bundle will be imported, but after 0.11, the `fesm2015` format bundle will
be imported, which causes error.
And since the only purpose of the `dist` folder of zone.js bundles is to keep backward
compatibility, in the original commit, I use package redirect to implement that, but
it is not fully backward compatible, we should keep the same dist structure as `0.10.3`.
PR Close #38797
2020-09-10 14:28:40 -04:00
|
|
|
expect(list).toEqual(expected);
|
2019-05-31 11:56:07 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|