Skip to content

feat(@schematics/angular): update compiler options target and module settings #17630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration/angular_cli/e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"target": "es2018",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified that the oldest version of node that we support is compatible with full es2018? I think it might be but I'm not sure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The oldest Node version that we support is 10.13.x, it seems that the only thing which is not supported is https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys

See: https://node.green/#ES2018

"types": [
"jasmine",
"jasminewd2",
Expand Down
4 changes: 2 additions & 2 deletions integration/angular_cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"module": "es2020",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"target": "es2016",
"lib": [
"es2018",
"dom"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
if (profilingEnabled) {
extraPlugins.push(
new debug.ProfilingPlugin({
outputPath: path.resolve(root, `chrome-profiler-events${targetInFileName}.json`),
outputPath: path.resolve(root, 'chrome-profiler-events.json'),
}),
);
}
Expand Down Expand Up @@ -302,7 +302,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
apply(compiler: Compiler) {
compiler.hooks.emit.tap('angular-cli-stats', compilation => {
const data = JSON.stringify(compilation.getStats().toJson('verbose'));
compilation.assets[`stats${targetInFileName}.json`] = new RawSource(data);
compilation.assets['stats.json'] = new RawSource(data);
});
}
})(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export enum ThresholdSeverity {
}

enum DifferentialBuildType {
ORIGINAL = 'es2015',
// FIXME: this should match the actual file suffix and not hardcoded.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮

ORIGINAL = 'es2016',
DOWNLEVEL = 'es5',
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('bundle-calculator', () => {
{
name: '0',
original: {
filename: 'foo-es2015.js',
filename: 'foo-es2016.js',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh uh. I didn't realize that we will start renaming the files in dist/ as well. Hmm. This file rename will break a lot of stuff in angular/angular (e.g size tracking) and invalidate docs guides.

Let's back off on the es2016 change and keep only the modules change.

In v11 we can create a proper plan for target=es2016 or maybe even higher (zones!).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to name the files something more generic maybe instead of the syntax version.

size: 1.25 * KB,
},
downlevel: {
Expand All @@ -141,7 +141,7 @@ describe('bundle-calculator', () => {
expect(failures.length).toBe(2);
expect(failures).toContain({
severity: ThresholdSeverity.Error,
message: jasmine.stringMatching('Exceeded maximum budget for foo-es2015.'),
message: jasmine.stringMatching('Exceeded maximum budget for foo-es2016.'),
});
expect(failures).toContain({
severity: ThresholdSeverity.Error,
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('bundle-calculator', () => {
name: '0',
// Individual builds are under budget, but combined they are over.
original: {
filename: 'foo-es2015.js',
filename: 'foo-es2016.js',
size: 0.5 * KB,
},
downlevel: {
Expand Down Expand Up @@ -240,7 +240,7 @@ describe('bundle-calculator', () => {
name: '0',
// Individual builds are under budget, but combined they are over.
original: {
filename: 'initial-es2015.js',
filename: 'initial-es2016.js',
size: 1.25 * KB,
},
downlevel: {
Expand All @@ -255,7 +255,7 @@ describe('bundle-calculator', () => {
expect(failures.length).toBe(2);
expect(failures).toContain({
severity: ThresholdSeverity.Error,
message: jasmine.stringMatching('Exceeded maximum budget for initial-es2015.'),
message: jasmine.stringMatching('Exceeded maximum budget for initial-es2016.'),
});
expect(failures).toContain({
severity: ThresholdSeverity.Error,
Expand Down Expand Up @@ -283,7 +283,7 @@ describe('bundle-calculator', () => {
name: '0',
// Individual builds are under budget, but combined they are over.
original: {
filename: 'initial-es2015.js',
filename: 'initial-es2016.js',
size: 0.5 * KB,
},
downlevel: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ describe('augment-index-html', () => {

it(`should emit correct script tags when having 'module' and 'non-module' js`, async () => {
const es2015JsFiles: FileInfo[] = [
{ file: 'runtime-es2015.js', extension: '.js', name: 'main' },
{ file: 'main-es2015.js', extension: '.js', name: 'main' },
{ file: 'runtime-es2015.js', extension: '.js', name: 'polyfills' },
{ file: 'polyfills-es2015.js', extension: '.js', name: 'polyfills' },
{ file: 'runtime-es2016.js', extension: '.js', name: 'main' },
{ file: 'main-es2016.js', extension: '.js', name: 'main' },
{ file: 'runtime-es2016.js', extension: '.js', name: 'polyfills' },
{ file: 'polyfills-es2016.js', extension: '.js', name: 'polyfills' },
];

const es5JsFiles: FileInfo[] = [
Expand Down Expand Up @@ -82,11 +82,11 @@ describe('augment-index-html', () => {
<link rel="stylesheet" href="styles.css">
</head>
<body>
<script src="runtime-es2015.js" type="module"></script>
<script src="polyfills-es2015.js" type="module"></script>
<script src="runtime-es2016.js" type="module"></script>
<script src="polyfills-es2016.js" type="module"></script>
<script src="runtime-es5.js" nomodule defer></script>
<script src="polyfills-es5.js" nomodule defer></script>
<script src="main-es2015.js" type="module"></script>
<script src="main-es2016.js" type="module"></script>
<script src="main-es5.js" nomodule defer></script>
</body>
</html>
Expand All @@ -98,7 +98,7 @@ describe('augment-index-html', () => {
async () => {
const es2015JsFiles: FileInfo[] = [
{ file: 'scripts.js', extension: '.js', name: 'scripts' },
{ file: 'main-es2015.js', extension: '.js', name: 'main' },
{ file: 'main-es2016.js', extension: '.js', name: 'main' },
];

const es5JsFiles: FileInfo[] = [
Expand All @@ -125,7 +125,7 @@ describe('augment-index-html', () => {
</head>
<body>
<script src="scripts.js" defer></script>
<script src="main-es2015.js" type="module"></script>
<script src="main-es2016.js" type="module"></script>
<script src="main-es5.js" nomodule defer></script>
</body>
</html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ describe('Browser Builder with differential loading', () => {
'favicon.ico',
'index.html',

'main-es2015.js',
'main-es2015.js.map',
'main-es2016.js',
'main-es2016.js.map',
'main-es5.js',
'main-es5.js.map',

'polyfills-es2015.js',
'polyfills-es2015.js.map',
'polyfills-es2016.js',
'polyfills-es2016.js.map',
'polyfills-es5.js',
'polyfills-es5.js.map',

'runtime-es2015.js',
'runtime-es2015.js.map',
'runtime-es2016.js',
'runtime-es2016.js.map',
'runtime-es5.js',
'runtime-es5.js.map',

'styles-es2015.js',
'styles-es2015.js.map',
'styles-es2016.js',
'styles-es2016.js.map',
'styles-es5.js',
'styles-es5.js.map',

'vendor-es2015.js',
'vendor-es2015.js.map',
'vendor-es2016.js',
'vendor-es2016.js.map',
'vendor-es5.js',
'vendor-es5.js.map',
] as PathFragment[];
Expand Down Expand Up @@ -178,17 +178,17 @@ describe('Browser Builder with differential loading', () => {
vendorChunk: false,
});
expect(await files['main-es5.js']).not.toContain('const ');
expect(await files['main-es2015.js']).toContain('const ');
expect(await files['main-es2016.js']).toContain('const ');
});

it('uses the right zone.js variant', async () => {
const { files } = await browserBuild(architect, host, target, { optimization: false });
expect(await files['polyfills-es5.js']).toContain('zone.js/dist/zone-legacy');
expect(await files['polyfills-es5.js']).toContain('registerElementPatch');
expect(await files['polyfills-es5.js']).toContain('zone.js/dist/zone-evergreen');
expect(await files['polyfills-es2015.js']).toContain('zone.js/dist/zone-evergreen');
expect(await files['polyfills-es2015.js']).not.toContain('zone.js/dist/zone-legacy');
expect(await files['polyfills-es2015.js']).not.toContain('registerElementPatch');
expect(await files['polyfills-es2016.js']).toContain('zone.js/dist/zone-evergreen');
expect(await files['polyfills-es2016.js']).not.toContain('zone.js/dist/zone-legacy');
expect(await files['polyfills-es2016.js']).not.toContain('registerElementPatch');
});

it('adds `type="module"` when differential loading is needed', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"target": "es2018",
"types": [
"jasmine",
"jasminewd2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"module": "esnext",
"target": "es2016",
"module": "es2020",
"typeRoots": [
"../node_modules/@types"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "es2015",
"target": "es2016",
"declaration": true,
"inlineSources": true,
"types": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"declaration": false,
"moduleResolution": "node",
"experimentalDecorators": true,
"target": "es2015",
"module": "esnext",
"target": "es2016",
"module": "es2020",
"typeRoots": [
"node_modules/@types"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"module": "es2020",
"types": []
},
"exclude": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"target": "es2018",
"types": [
"jasmine",
"jasminewd2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
"version": "10.0.0-beta.3",
"factory": "./update-10/update-angular-config",
"description": "Remove deprecated 'evalSourceMap', `profile`, 'skipAppShell' and 'vendorSourceMap' from 'angular.json'."
},
"update-module-and-target-compiler-options": {
"version": "10.0.0-next.3",
"factory": "./update-10/update-module-and-target-compiler-options",
"description": "Update 'module' and 'target' TypeScript compiler options."
}
}
}
Loading