docs: update docs to use new zone.js entry-points (#40823)

In CLI version 12, the old style of imports is no longer supported.

PR Close #40823
This commit is contained in:
Alan Agius 2021-02-15 10:08:30 +01:00 committed by Andrew Scott
parent 03de2f2b78
commit d51d39cb4c
29 changed files with 51 additions and 44 deletions

View File

@ -6,7 +6,7 @@ declare var jasmine;
import './polyfills';
import 'zone.js/dist/zone-testing';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {

View File

@ -131,7 +131,7 @@ describe('Angular async helper', () => {
// #docregion fake-async-test-rxjs
it('should get Date diff correctly in fakeAsync with rxjs scheduler', fakeAsync(() => {
// need to add `import 'zone.js/dist/zone-patch-rxjs-fake-async'
// need to add `import 'zone.js/plugins/zone-patch-rxjs-fake-async'
// to patch rxjs scheduler
let result = null;
of('hello').pipe(delay(1000)).subscribe(v => {
@ -156,7 +156,7 @@ describe('Angular async helper', () => {
// #docregion fake-async-test-clock
describe('use jasmine.clock()', () => {
// need to config __zone_symbol__fakeAsyncPatchLock flag
// before loading zone.js/dist/zone-testing
// before loading zone.js/testing
beforeEach(() => {
jasmine.clock().install();
});
@ -180,7 +180,7 @@ describe('Angular async helper', () => {
// do a jsonp call which is not zone aware
}
// need to config __zone_symbol__supportWaitUnResolvedChainedPromise flag
// before loading zone.js/dist/zone-testing
// before loading zone.js/testing
it('should wait until promise.then is called', waitForAsync(() => {
let finished = false;
new Promise((res, rej) => {

View File

@ -3,7 +3,7 @@
// Import patch to make async `HTMLCanvasElement` methods (such as `.toBlob()`) Zone.js-aware.
// Either import in `polyfills.ts` (if used in more than one places in the app) or in the component
// file using `HTMLCanvasElement` (if it is only used in a single file).
import 'zone.js/dist/zone-patch-canvas';
import 'zone.js/plugins/zone-patch-canvas';
// #enddocregion import-canvas-patch
// #docregion main
import { Component, AfterViewInit, ViewChild, ElementRef } from '@angular/core';

View File

@ -6,7 +6,7 @@ declare var jasmine;
import './polyfills';
import 'zone.js/dist/zone-testing';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {

View File

@ -1,4 +1,4 @@
import 'zone.js/dist/zone-node';
import 'zone.js/node';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';

View File

@ -142,7 +142,7 @@ The following example shows how you modify the `server.ts` file to provide the `
* Set `bootstrap: AppServerModuleNgFactory` in the `ngExpressEngine` call.
<code-example language="typescript" header="server.ts">
import 'zone.js/dist/zone-node';
import 'zone.js/node';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';

View File

@ -371,7 +371,7 @@ value becomes available. The test must become _asynchronous_.
#### Async test with _fakeAsync()_
To use `fakeAsync()` functionality, you must import `zone.js/dist/zone-testing` in your test setup file.
To use `fakeAsync()` functionality, you must import `zone.js/testing` in your test setup file.
If you created your project with the Angular CLI, `zone-testing` is already imported in `src/test.ts`.
The following test confirms the expected behavior when the service returns an `ErrorObservable`.
@ -453,7 +453,7 @@ If you use the Angular CLI, configure this flag in `src/test.ts`.
```
(window as any)['__zone_symbol__fakeAsyncPatchLock'] = true;
import 'zone.js/dist/zone-testing';
import 'zone.js/testing';
```
<code-example
@ -463,7 +463,7 @@ import 'zone.js/dist/zone-testing';
#### Using the RxJS scheduler inside fakeAsync()
You can also use RxJS scheduler in `fakeAsync()` just like using `setTimeout()` or `setInterval()`, but you need to import `zone.js/dist/zone-patch-rxjs-fake-async` to patch RxJS scheduler.
You can also use RxJS scheduler in `fakeAsync()` just like using `setTimeout()` or `setInterval()`, but you need to import `zone.js/plugins/zone-patch-rxjs-fake-async` to patch RxJS scheduler.
<code-example
path="testing/src/app/demo/async-helper.spec.ts"
region="fake-async-test-rxjs">
@ -583,7 +583,7 @@ Then you can assert that the quote element displays the expected text.
#### Async test with _waitForAsync()_
To use `waitForAsync()` functionality, you must import `zone.js/dist/zone-testing` in your test setup file.
To use `waitForAsync()` functionality, you must import `zone.js/testing` in your test setup file.
If you created your project with the Angular CLI, `zone-testing` is already imported in `src/test.ts`.
<div class="alert is-helpful">

View File

@ -308,7 +308,7 @@ So when IE is refreshed (manually or automatically by `ng serve`), sometimes the
## Appendix: Test using `fakeAsync()/waitForAsync()`
If you use the `fakeAsync()/waitForAsync()` helper function to run unit tests (for details, read the [Testing guide](guide/testing-components-scenarios#fake-async)), you need to import `zone.js/dist/zone-testing` in your test setup file.
If you use the `fakeAsync()/waitForAsync()` helper function to run unit tests (for details, read the [Testing guide](guide/testing-components-scenarios#fake-async)), you need to import `zone.js/testing` in your test setup file.
<div class="alert is-important">
If you create project with `Angular/CLI`, it is already imported in `src/test.ts`.
@ -317,12 +317,12 @@ If you create project with `Angular/CLI`, it is already imported in `src/test.ts
And in the earlier versions of `Angular`, the following files were imported or added in your html file:
```
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/proxy';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import 'zone.js/plugins/long-stack-trace-zone';
import 'zone.js/plugins/proxy';
import 'zone.js/plugins/sync-test';
import 'zone.js/plugins/jasmine-patch';
import 'zone.js/plugins/async-test';
import 'zone.js/plugins/fake-async-test';
```
You can still load those files separately, but the order is important, you must import `proxy` before `sync-test`, `async-test`, `fake-async-test` and `jasmine-patch`. And you also need to import `sync-test` before `jasmine-patch`, so it is recommended to just import `zone-testing` instead of loading those separated files.

View File

@ -323,7 +323,7 @@ Angular also supports passive event listeners. For example, you can use the foll
```
import './zone-flags';
import 'zone.js/dist/zone'; // Included with Angular CLI.
import 'zone.js'; // Included with Angular CLI.
```
After those steps, if you add event listeners for the `scroll` event, the listeners will be `passive`.

View File

@ -352,7 +352,7 @@ If you are using the Angular CLI, this step is done automatically, and you will
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
import 'zone.js'; // Included with Angular CLI.
```
Before importing the `zone.js` package, you can set the following configurations:
@ -380,7 +380,7 @@ Next, import `zone-flags` before you import `zone.js` in the `polyfills.ts`:
* Zone JS is required by default for Angular.
*/
import `./zone-flags`;
import 'zone.js/dist/zone'; // Included with Angular CLI.
import 'zone.js'; // Included with Angular CLI.
```
For more information about what you can configure, see the [Zone.js](https://github.com/angular/angular/tree/master/packages/zone.js) documentation.
@ -406,7 +406,7 @@ To remove Zone.js, make the following changes.
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
// import 'zone.js/dist/zone'; // Included with Angular CLI.
// import 'zone.js'; // Included with Angular CLI.
```
2. Bootstrap Angular with the `noop` zone in `src/main.ts`:

View File

@ -103,7 +103,7 @@
"@webcomponents/custom-elements": "1.2.1",
"rxjs": "^6.5.3",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.1100.1",

View File

@ -55,7 +55,7 @@
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
import 'zone.js'; // Included with Angular CLI.
/***************************************************************************************************

View File

@ -1,6 +1,6 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,

View File

@ -26,7 +26,7 @@
"angular-route": "1.8.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.2",

View File

@ -24,7 +24,7 @@
"angular-in-memory-web-api": "~0.11.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.2",

View File

@ -13,4 +13,4 @@ export const environment = {
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.

View File

@ -57,7 +57,7 @@
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
import 'zone.js'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS

View File

@ -1,6 +1,6 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,

View File

@ -26,7 +26,7 @@
"angular-in-memory-web-api": "~0.11.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.2",

View File

@ -57,7 +57,7 @@
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
import 'zone.js'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS

View File

@ -28,7 +28,7 @@
"angular-in-memory-web-api": "~0.11.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.2",

View File

@ -61,7 +61,7 @@ import '@angular/localize/init';
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
import 'zone.js'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS

View File

@ -25,7 +25,7 @@
"angular-in-memory-web-api": "~0.11.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.2",

View File

@ -39,7 +39,7 @@
"core-js": "^2.5.4",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular/compiler-cli": "~11.0.1",

View File

@ -31,7 +31,7 @@
"express": "^4.15.2",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.2",

View File

@ -44,7 +44,7 @@
"rxjs": "~6.6.0",
"systemjs": "0.19.39",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.2",

View File

@ -12663,3 +12663,10 @@ zone.js@~0.10.3:
version "0.10.3"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.10.3.tgz#3e5e4da03c607c9dcd92e37dd35687a14a140c16"
integrity sha512-LXVLVEq0NNOqK/fLJo3d0kfzd4sxwn2/h67/02pjCjfKDxgx1i9QqpvtHD8CrBnSSwMw5+dy11O7FRX5mkO7Cg==
zone.js@~0.11.4:
version "0.11.4"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.11.4.tgz#0f70dcf6aba80f698af5735cbb257969396e8025"
integrity sha512-DDh2Ab+A/B+9mJyajPjHFPWfYU1H+pdun4wnnk0OcQTNjem1XQSZ2CDW+rfZEUDjv5M19SBqAkjZi0x5wuB5Qw==
dependencies:
tslib "^2.0.0"

View File

@ -14704,9 +14704,9 @@ zone.js@~0.10.3:
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.10.3.tgz#3e5e4da03c607c9dcd92e37dd35687a14a140c16"
integrity sha512-LXVLVEq0NNOqK/fLJo3d0kfzd4sxwn2/h67/02pjCjfKDxgx1i9QqpvtHD8CrBnSSwMw5+dy11O7FRX5mkO7Cg==
zone.js@~0.11.3:
version "0.11.3"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.11.3.tgz#255a6313174731cc014d63233ef04fd9858da375"
integrity sha512-Y4hTHoh4VcxU5BDGAqEoOnOiyT254w6CiHtpQxAJUSMZPyVgdbKf+5R7Mwz6xsPhMIeBXk5rTopRZDpjssTCUg==
zone.js@~0.11.4:
version "0.11.4"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.11.4.tgz#0f70dcf6aba80f698af5735cbb257969396e8025"
integrity sha512-DDh2Ab+A/B+9mJyajPjHFPWfYU1H+pdun4wnnk0OcQTNjem1XQSZ2CDW+rfZEUDjv5M19SBqAkjZi0x5wuB5Qw==
dependencies:
tslib "^2.0.0"

View File

@ -7,7 +7,7 @@
mkdir tmp
cd tmp
npm init -y
npm install typescript@~3.8.3 rxjs@^6.5.3 zone.js@~0.11.3 @bazel/typescript@^1.0.0 rollup@^1.20.0 rollup-plugin-commonjs@^9.0.0 rollup-plugin-node-resolve@^4.2.0 rollup-plugin-sourcemaps@0.4.0 @angular/{animations,bazel,common,compiler,compiler-cli,core,elements,forms,language-service,localize,platform-browser,platform-browser-dynamic,platform-server,router,service-worker,upgrade}@next --save
npm install typescript@~3.8.3 rxjs@^6.5.3 zone.js@~0.11.4 @bazel/typescript@^1.0.0 rollup@^1.20.0 rollup-plugin-commonjs@^9.0.0 rollup-plugin-node-resolve@^4.2.0 rollup-plugin-sourcemaps@0.4.0 @angular/{animations,bazel,common,compiler,compiler-cli,core,elements,forms,language-service,localize,platform-browser,platform-browser-dynamic,platform-server,router,service-worker,upgrade}@next --save
cd ..
rm -rf tmp