From aaf9b31fb472826c279a720cc875007987f9aa6f Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 17 Feb 2021 08:46:48 +0100 Subject: [PATCH] feat(core): drop support for zone.js 0.10.x (#40823) With this change we drop support for zone.js 0.10.x. This is needed because in version 12 the CLI will only work with `~0.11.4`. See angular/angular-cli#20034. BREAKING CHANGE: Minimum supported `zone.js` version is `0.11.4` PR Close #40823 --- .../compiler-cli/integrationtest/test/init.ts | 4 +-- packages/core/package.json | 2 +- packages/core/src/testability/testability.ts | 2 +- packages/core/testing/src/async.ts | 4 +-- packages/core/testing/src/fake_async.ts | 2 +- .../localize/schematics/ng-add/index_spec.ts | 2 +- packages/zone.js/MODULE.md | 8 +++--- packages/zone.js/NON-STANDARD-APIS.md | 25 +++++++++---------- packages/zone.js/lib/zone-spec/async-test.ts | 4 +-- .../zone.js/lib/zone-spec/fake-async-test.ts | 2 +- 10 files changed, 27 insertions(+), 28 deletions(-) diff --git a/packages/compiler-cli/integrationtest/test/init.ts b/packages/compiler-cli/integrationtest/test/init.ts index 869005a110..658b708e69 100644 --- a/packages/compiler-cli/integrationtest/test/init.ts +++ b/packages/compiler-cli/integrationtest/test/init.ts @@ -8,8 +8,8 @@ // import zone.js from npm here because integration test will load zone.js // from built npm_package instead of source -import 'zone.js/dist/zone-node'; -import 'zone.js/dist/zone-testing'; +import 'zone.js/node'; +import 'zone.js/testing'; // Only needed to satisfy the check in core/src/util/decorators.ts // TODO(alexeagle): maybe remove that check? require('reflect-metadata'); diff --git a/packages/core/package.json b/packages/core/package.json index e01bce8c7d..a75bfaa07e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,7 +9,7 @@ }, "peerDependencies": { "rxjs": "^6.5.3", - "zone.js": "^0.10.2 || ^0.11.3" + "zone.js": "~0.11.4" }, "repository": { "type": "git", diff --git a/packages/core/src/testability/testability.ts b/packages/core/src/testability/testability.ts index f24c852839..55d6e1f9b3 100644 --- a/packages/core/src/testability/testability.ts +++ b/packages/core/src/testability/testability.ts @@ -199,7 +199,7 @@ export class Testability implements PublicTestability { if (updateCb && !this.taskTrackingZone) { throw new Error( 'Task tracking zone is required when passing an update callback to ' + - 'whenStable(). Is "zone.js/dist/task-tracking.js" loaded?'); + 'whenStable(). Is "zone.js/plugins/task-tracking" loaded?'); } // These arguments are 'Function' above to keep the public API simple. this.addCallback(doneCb as DoneCallback, timeout, updateCb as UpdateCallback); diff --git a/packages/core/testing/src/async.ts b/packages/core/testing/src/async.ts index a3ff66b3e2..e43372ec42 100644 --- a/packages/core/testing/src/async.ts +++ b/packages/core/testing/src/async.ts @@ -28,7 +28,7 @@ export function waitForAsync(fn: Function): (done: any) => any { return function() { return Promise.reject( 'Zone is needed for the waitForAsync() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/zone.js'); + 'Please make sure that your environment includes zone.js'); }; } const asyncTest = _Zone && _Zone[_Zone.__symbol__('asyncTest')]; @@ -38,7 +38,7 @@ export function waitForAsync(fn: Function): (done: any) => any { return function() { return Promise.reject( 'zone-testing.js is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/zone-testing.js'); + 'Please make sure that your environment includes zone.js/testing'); }; } diff --git a/packages/core/testing/src/fake_async.ts b/packages/core/testing/src/fake_async.ts index 184e2e553a..1c57da22c3 100644 --- a/packages/core/testing/src/fake_async.ts +++ b/packages/core/testing/src/fake_async.ts @@ -10,7 +10,7 @@ const fakeAsyncTestModule = _Zone && _Zone[_Zone.__symbol__('fakeAsyncTest')]; const fakeAsyncTestModuleNotLoadedErrorMessage = `zone-testing.js is needed for the fakeAsync() test helper but could not be found. - Please make sure that your environment includes zone.js/dist/zone-testing.js`; + Please make sure that your environment includes zone.js/testing`; /** * Clears out the shared fake async zone for a test. diff --git a/packages/localize/schematics/ng-add/index_spec.ts b/packages/localize/schematics/ng-add/index_spec.ts index 11457db983..f91777bb89 100644 --- a/packages/localize/schematics/ng-add/index_spec.ts +++ b/packages/localize/schematics/ng-add/index_spec.ts @@ -22,7 +22,7 @@ describe('ng-add schematic', () => { `/*************************************************************************************************** * Zone JS is required by default for Angular itself. */ -import 'zone.js/dist/zone';`; +import 'zone.js';`; const mainServerContent = `import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; if (environment.production) { diff --git a/packages/zone.js/MODULE.md b/packages/zone.js/MODULE.md index 6bb5219577..fef300bb92 100644 --- a/packages/zone.js/MODULE.md +++ b/packages/zone.js/MODULE.md @@ -85,12 +85,12 @@ you can do like this. } ]; - + ``` - Error -By default, `zone.js/dist/zone-error` will not be loaded for performance concern. +By default, `zone.js/plugins/zone-error` will not be loaded for performance concern. This package will provide following functionality. 1. Error inherit: handle `extend Error` issue. @@ -125,13 +125,13 @@ This package will provide following functionality. The second feature will slow down the `Error` performance, so `zone.js` provide a flag to let you be able to control the behavior. The flag is `__Zone_Error_ZoneJsInternalStackFrames_policy`. And the available options is: - 1. default: this is the default one, if you load `zone.js/dist/zone-error` without + 1. default: this is the default one, if you load `zone.js/plugins/zone-error` without setting the flag, `default` will be used, and `ZoneJsInternalStackFrames` will be available when `new Error()`, you can get a `error.stack` which is `zone stack free`. But this will slow down `new Error()` a little bit. 2. disable: this will disable `ZoneJsInternalStackFrames` feature, and if you load - `zone.js/dist/zone-error`, you will only get a `wrapped Error` which can handle + `zone.js/plugins/zone-error`, you will only get a `wrapped Error` which can handle `Error inherit` issue. 3. lazy: this is a feature to let you be able to get `ZoneJsInternalStackFrames` feature, diff --git a/packages/zone.js/NON-STANDARD-APIS.md b/packages/zone.js/NON-STANDARD-APIS.md index 357a1c2022..4d57fb74c6 100644 --- a/packages/zone.js/NON-STANDARD-APIS.md +++ b/packages/zone.js/NON-STANDARD-APIS.md @@ -14,7 +14,6 @@ But there are still a lot of non-standard APIs that are not patched by default, * webcomponents Usage: - ``` @@ -45,8 +44,8 @@ Angular Usage: in polyfills.ts, import the `zone-bluebird` package. ``` -import 'zone.js/dist/zone'; // Included with Angular CLI. -import 'zone.js/dist/zone-bluebird'; +import 'zone.js'; // Included with Angular CLI. +import 'zone.js/plugins/zone-bluebird'; ``` in main.ts, patch bluebird. @@ -67,7 +66,7 @@ Node Sample Usage: ``` require('zone.js'); const Bluebird = require('bluebird'); -require('zone.js/dist/zone-bluebird'); +require('zone.js/plugins/zone-bluebird'); Zone[Zone['__symbol__']('bluebird')](Bluebird); Zone.current.fork({ name: 'bluebird' @@ -178,7 +177,7 @@ is patched, so each asynchronous call will run in the correct zone. For example, in an Angular application, you can load this patch in your `app.module.ts`. ``` -import 'zone.js/dist/zone-patch-rxjs'; +import 'zone.js/plugins/zone-patch-rxjs'; ``` * electron @@ -194,9 +193,9 @@ In electron, we patched the following APIs with `zone.js` add following line into `polyfill.ts` after loading zone-mix. ``` -//import 'zone.js/dist/zone'; // originally added by angular-cli, comment it out -import 'zone.js/dist/zone-mix'; // add zone-mix to patch both Browser and Nodejs -import 'zone.js/dist/zone-patch-electron'; // add zone-patch-electron to patch Electron native API +//import 'zone.js'; // originally added by angular-cli, comment it out +import 'zone.js/mix'; // add zone-mix to patch both Browser and Nodejs +import 'zone.js/plugins/zone-patch-electron'; // add zone-patch-electron to patch Electron native API ``` there is a sampel repo [zone-electron](https://github.com/JiaLiPassion/zone-electron). @@ -207,8 +206,8 @@ user need to patch `io` themselves just like following code. ```javascript - - + +