Skip to content

Commit 09e79ad

Browse files
committed
fix(@angular/cli): strip decorators with Angular 5+
We feel build This PR defualts `build-optimizer` when using Angular 5+ on a production build with `--aot`. It can still be turned off with `--no-build-optimizer` (or `--build-optimizer=false`). Fix #8050
1 parent 7f5529d commit 09e79ad

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

docs/documentation/build.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Flag | `--dev` | `--prod`
8181
`--sourcemaps` | `true` | `false`
8282
`--extract-css` | `false` | `true`
8383
`--named-chunks`   | `true` | `false`
84+
`--build-optimizer` | `false` | `true` in Angular 5+
8485

8586
`--extract-licenses` Extract all licenses in a separate file, in the case of production builds only.
8687
`--i18n-file` Localization file to use for i18n.
@@ -353,7 +354,7 @@ Note: service worker support is experimental and subject to change.
353354
<code>--build-optimizer</code>
354355
</p>
355356
<p>
356-
(Experimental) Enables @angular-devkit/build-optimizer optimizations when using `--aot`.
357+
Enables @angular-devkit/build-optimizer optimizations when using `--aot`.
357358
</p>
358359
</details>
359360

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"homepage": "https://github.com/angular/angular-cli",
4343
"dependencies": {
44-
"@angular-devkit/build-optimizer": "~0.0.23",
44+
"@angular-devkit/build-optimizer": "~0.0.28",
4545
"@angular-devkit/schematics": "~0.0.25",
4646
"@schematics/angular": "~0.0.38",
4747
"autoprefixer": "^6.5.3",

packages/@angular/cli/commands/build.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ export const baseBuildCommandOptions: any = [
166166
{
167167
name: 'build-optimizer',
168168
type: Boolean,
169-
default: false,
170-
description: '(Experimental) Enables @angular-devkit/build-optimizer '
171-
+ 'optimizations when using `--aot`.'
169+
description: 'Enables @angular-devkit/build-optimizer optimizations when using `--aot`.'
172170
},
173171
{
174172
name: 'named-chunks',

packages/@angular/cli/models/webpack-config.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AngularCompilerPlugin } from '@ngtools/webpack';
12
import { readTsconfig } from '../utilities/read-tsconfig';
23
const webpackMerge = require('webpack-merge');
34
import { CliConfig } from './config';
@@ -94,7 +95,8 @@ export class NgCliWebpackConfig<T extends BuildOptions = BuildOptions> {
9495
sourcemaps: true,
9596
extractCss: false,
9697
namedChunks: true,
97-
aot: false
98+
aot: false,
99+
buildOptimizer: false
98100
},
99101
production: {
100102
environment: 'prod',
@@ -106,7 +108,14 @@ export class NgCliWebpackConfig<T extends BuildOptions = BuildOptions> {
106108
}
107109
};
108110

109-
return Object.assign({}, targetDefaults[buildOptions.target], buildOptions);
111+
const merged = Object.assign({}, targetDefaults[buildOptions.target], buildOptions);
112+
113+
// Use Build Optimizer on prod AOT builds by default when AngularCompilerPlugin is supported.
114+
const buildOptimizer = {
115+
buildOptimizer: merged.aot && AngularCompilerPlugin.isSupported()
116+
};
117+
118+
return Object.assign({}, buildOptimizer, merged);
110119
}
111120

112121
// Fill in defaults from .angular-cli.json

packages/@angular/cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"homepage": "https://github.com/angular/angular-cli",
2929
"dependencies": {
30-
"@angular-devkit/build-optimizer": "~0.0.18",
30+
"@angular-devkit/build-optimizer": "~0.0.28",
3131
"@angular-devkit/schematics": "~0.0.25",
3232
"@ngtools/json-schema": "1.1.0",
3333
"@ngtools/webpack": "1.8.0-rc.0",

0 commit comments

Comments
 (0)