Skip to content

Commit 0fd3c55

Browse files
alan-agius4dgp1130
authored andcommitted
feat(@schematics/angular): update compiler options target and module settings
With this change we update the target and module settings of various compilation units. - We replace ES5 target in protractor. Protractor runs on Node.Js which support ES2018 - For applications we now use `ES2020` instead of `ESNext` as a module to avoid unexpected changes in behaviour This changes also adds a migration to update existing projects and also removes `module` from the Universal tsconfig as per #17352 to enable lazy loading on the server.
1 parent 13b0763 commit 0fd3c55

File tree

15 files changed

+283
-12
lines changed

15 files changed

+283
-12
lines changed

integration/angular_cli/e2e/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"outDir": "../out-tsc/e2e",
55
"module": "commonjs",
6-
"target": "es5",
6+
"target": "es2018",
77
"types": [
88
"jasmine",
99
"jasminewd2",

integration/angular_cli/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"declaration": false,
88
"downlevelIteration": true,
99
"experimentalDecorators": true,
10-
"module": "esnext",
10+
"module": "es2020",
1111
"moduleResolution": "node",
1212
"importHelpers": true,
1313
"target": "es2015",

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
194194
if (profilingEnabled) {
195195
extraPlugins.push(
196196
new debug.ProfilingPlugin({
197-
outputPath: path.resolve(root, `chrome-profiler-events${targetInFileName}.json`),
197+
outputPath: path.resolve(root, 'chrome-profiler-events.json'),
198198
}),
199199
);
200200
}
@@ -303,7 +303,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
303303
apply(compiler: Compiler) {
304304
compiler.hooks.emit.tap('angular-cli-stats', compilation => {
305305
const data = JSON.stringify(compilation.getStats().toJson('verbose'));
306-
compilation.assets[`stats${targetInFileName}.json`] = new RawSource(data);
306+
compilation.assets['stats.json'] = new RawSource(data);
307307
});
308308
}
309309
})(),

packages/angular_devkit/build_angular/src/angular-cli-files/utilities/bundle-calculator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export enum ThresholdSeverity {
3232
}
3333

3434
enum DifferentialBuildType {
35+
// FIXME: this should match the actual file suffix and not hardcoded.
3536
ORIGINAL = 'es2015',
3637
DOWNLEVEL = 'es5',
3738
}

packages/angular_devkit/build_angular/test/hello-world-app/e2e/tsconfig.e2e.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"outDir": "../out-tsc/e2e",
55
"module": "commonjs",
6-
"target": "es5",
6+
"target": "es2018",
77
"types": [
88
"jasmine",
99
"jasminewd2",

packages/angular_devkit/build_angular/test/hello-world-app/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"emitDecoratorMetadata": true,
1111
"experimentalDecorators": true,
1212
"target": "es2015",
13-
"module": "esnext",
13+
"module": "es2020",
1414
"typeRoots": [
1515
"../node_modules/@types"
1616
],

packages/angular_devkit/build_ng_packagr/test/ng-packaged/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"moduleResolution": "node",
99
"experimentalDecorators": true,
1010
"target": "es2015",
11-
"module": "esnext",
11+
"module": "es2020",
1212
"typeRoots": [
1313
"node_modules/@types"
1414
],

packages/angular_devkit/build_webpack/test/angular-app/src/tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../out-tsc/app",
5-
"module": "es2015",
5+
"module": "es2020",
66
"types": []
77
},
88
"exclude": [

packages/schematics/angular/e2e/files/tsconfig.json.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/e2e",
55
"module": "commonjs",
6-
"target": "es5",
6+
"target": "es2018",
77
"types": [
88
"jasmine",
99
"jasminewd2",

packages/schematics/angular/migrations/migration-collection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@
8989
"version": "10.0.0-beta.3",
9090
"factory": "./update-10/side-effects-package-json",
9191
"description": "Create a special 'package.json' file that is used to tell the tools and bundlers whether the code under the app directory is free of code with non-local side-effect."
92+
},
93+
"update-module-and-target-compiler-options": {
94+
"version": "10.0.0-beta.3",
95+
"factory": "./update-10/update-module-and-target-compiler-options",
96+
"description": "Update 'module' and 'target' TypeScript compiler options."
9297
}
9398
}
9499
}

0 commit comments

Comments
 (0)