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
This commit is contained in:

committed by
Misko Hevery

parent
c4b8964424
commit
a33d630a21
@ -182,7 +182,7 @@ describe('Zone.js npm_package', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('dist file list', () => {
|
||||
describe('bundles file list', () => {
|
||||
it('should contain all files', () => {
|
||||
const expected = [
|
||||
'async-test.js',
|
||||
@ -277,114 +277,86 @@ describe('Zone.js npm_package', () => {
|
||||
|
||||
describe('backward compatible check', () => {
|
||||
it('should contain all original folders in /dist', () => {
|
||||
const list = shx.ls('./dist').stdout.split('\n').sort().slice(1);
|
||||
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-mix',
|
||||
'zone-mix.min',
|
||||
'zone-node',
|
||||
'zone-node.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',
|
||||
'zone-testing-bundle',
|
||||
'zone-testing-bundle.min',
|
||||
'zone-testing-node-bundle',
|
||||
'zone-testing-node-bundle.min',
|
||||
'zone-testing',
|
||||
'zone-testing.min',
|
||||
'zone',
|
||||
'zone.min',
|
||||
'zone_externs',
|
||||
'zone-evergreen',
|
||||
'zone-evergreen.min',
|
||||
'zone-evergreen-testing-bundle',
|
||||
'zone-evergreen-testing-bundle.min',
|
||||
'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',
|
||||
].sort();
|
||||
checkInSubFolder('./dist', () => {
|
||||
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`);
|
||||
if (list[i].indexOf('_externs') !== -1) {
|
||||
expect(packageJson).toContain(`"name": "zone.js/${list[i]}"`);
|
||||
expect(packageJson).toContain(`"main": "../../${list[i]}.js"`);
|
||||
expect(packageJson).toContain(`"fesm2015": "../../${list[i]}.js"`);
|
||||
expect(packageJson).toContain(`"es2015": "../../${list[i]}.js"`);
|
||||
expect(packageJson).toContain(`"module": "../../${list[i]}.js"`);
|
||||
continue;
|
||||
}
|
||||
if (list[i].indexOf('evergreen') === -1) {
|
||||
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"`);
|
||||
} else {
|
||||
const removeEvergreen = list[i].replace('-evergreen', '');
|
||||
expect(packageJson).toContain(`"name": "zone.js/${list[i]}"`);
|
||||
expect(packageJson).toContain(`"main": "../../fesm2015/${removeEvergreen}.js"`);
|
||||
expect(packageJson).toContain(`"fesm2015": "../../fesm2015/${removeEvergreen}.js"`);
|
||||
expect(packageJson).toContain(`"es2015": "../../fesm2015/${removeEvergreen}.js"`);
|
||||
expect(packageJson).toContain(`"module": "../../fesm2015/${removeEvergreen}.js"`);
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(list).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user