Skip to content

Commit a379624

Browse files
alan-agius4filipesilva
authored andcommitted
fix(@ngtools/webpack): show zone.js incompatibility warning when using ES2017+
Closes: #19226
1 parent eef862c commit a379624

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

packages/angular_devkit/build_angular/src/webpack/configs/common.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
BuildOptimizerWebpackPlugin,
1010
buildOptimizerLoaderPath,
1111
} from '@angular-devkit/build-optimizer';
12-
import { tags } from '@angular-devkit/core';
1312
import * as CopyWebpackPlugin from 'copy-webpack-plugin';
1413
import { existsSync } from 'fs';
1514
import * as path from 'path';
@@ -446,17 +445,6 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
446445
);
447446
}
448447

449-
if (
450-
wco.tsConfig.options.target !== undefined &&
451-
wco.tsConfig.options.target >= ScriptTarget.ES2017
452-
) {
453-
wco.logger.warn(tags.stripIndent`
454-
Warning: Zone.js does not support native async/await in ES2017.
455-
These blocks are not intercepted by zone.js and will not triggering change detection.
456-
See: https://github.com/angular/zone.js/pull/1140 for more information.
457-
`);
458-
}
459-
460448
return {
461449
mode: scriptsOptimization || stylesOptimization ? 'production' : 'development',
462450
devtool: false,

packages/ngtools/webpack/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ The loader works with webpack plugin to compile your TypeScript. It's important
6363
* `i18nOutFile`. Optional and only used for View Engine compilations. The name of the file to write extractions to.
6464
* `i18nOutFormat`. Optional and only used for View Engine compilations. The format of the localization file where extractions will be written to.
6565
* `locale`. Optional and only used for View Engine compilations. Locale to use for i18n.
66+
* `suppressZoneJsIncompatibilityWarning`. Optional, defaults to `false`. A Zone.js incompatibility warning is shown when the compilation target is ES2017+. Zone.js does not support native async/await in ES2017+. These blocks are not intercepted by zone.js and will not triggering change detection.
67+
See https://github.com/angular/zone.js/pull/1140 for more information.
6668

6769
## Features
6870
The benefits and ability of using [`@ngtools/webpack`](https://www.npmjs.com/~ngtools) standalone from the Angular CLI as presented in [Stephen Fluin's Angular CLI talk](https://youtu.be/uBRK6cTr4Vk?t=6m45s) at Angular Connect 2016:

packages/ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ export class AngularCompilerPlugin {
269269
this._discoverLazyRoutes = options.discoverLazyRoutes;
270270
}
271271

272+
if (
273+
!this.options.suppressZoneJsIncompatibilityWarning &&
274+
this._compilerOptions.target !== undefined &&
275+
this._compilerOptions.target >= ts.ScriptTarget.ES2017
276+
) {
277+
this._warnings.push(
278+
'Zone.js does not support native async/await in ES2017+.\n' +
279+
'These blocks are not intercepted by zone.js and will not triggering change detection.\n' +
280+
'See: https://github.com/angular/zone.js/pull/1140 for more information.',
281+
);
282+
}
283+
272284
if (this._discoverLazyRoutes === false && this.options.additionalLazyModuleResources
273285
&& this.options.additionalLazyModuleResources.length > 0) {
274286
this._warnings.push(

packages/ngtools/webpack/src/interfaces.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,12 @@ export interface AngularCompilerPluginOptions {
8383

8484
host?: virtualFs.Host<fs.Stats>;
8585
platformTransformers?: ts.TransformerFactory<ts.SourceFile>[];
86+
87+
/**
88+
* Suppress Zone.js incompatibility warning when using ES2017+.
89+
* Zone.js does not support native async/await in ES2017+.
90+
* These blocks are not intercepted by zone.js and will not triggering change detection.
91+
* @see https://github.com/angular/zone.js/pull/1140
92+
*/
93+
suppressZoneJsIncompatibilityWarning?: boolean;
8694
}

0 commit comments

Comments
 (0)