Skip to content

Commit 0230806

Browse files
committed
feat(@angular/cli): add scope hoisting
1 parent 8bad46e commit 0230806

File tree

9 files changed

+24
-16
lines changed

9 files changed

+24
-16
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@
5353
"ember-cli-string-utils": "^1.0.0",
5454
"enhanced-resolve": "^3.1.0",
5555
"exports-loader": "^0.6.3",
56-
"extract-text-webpack-plugin": "^2.1.0",
56+
"extract-text-webpack-plugin": "3.0.0-beta.3",
5757
"file-loader": "^0.10.0",
5858
"fs-extra": "~3.0.1",
5959
"get-caller-file": "^1.0.0",
6060
"glob": "^7.0.3",
6161
"heimdalljs": "^0.2.4",
6262
"heimdalljs-logger": "^0.1.9",
63-
"html-webpack-plugin": "^2.19.0",
63+
"html-webpack-plugin": "^2.29.0",
6464
"inflection": "^1.7.0",
6565
"inquirer": "^3.0.0",
6666
"isbinaryfile": "^3.0.0",
@@ -98,8 +98,8 @@
9898
"typescript": "~2.3.1",
9999
"url-loader": "^0.5.7",
100100
"walk-sync": "^0.3.1",
101-
"webpack": "~2.4.0",
102-
"webpack-dev-middleware": "^1.10.2",
101+
"webpack": "~3.0.0",
102+
"webpack-dev-middleware": "^1.11.0",
103103
"webpack-dev-server": "~2.4.5",
104104
"webpack-merge": "^2.4.0",
105105
"zone.js": "^0.8.4"

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

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export const baseBuildCommandOptions: any = [
4343
{
4444
name: 'vendor-chunk',
4545
type: Boolean,
46-
default: true,
4746
aliases: ['vc'],
4847
description: 'Use a separate bundle containing only vendor libraries.'
4948
},

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ export class NgCliWebpackConfig {
7979
environment: 'dev',
8080
outputHashing: 'media',
8181
sourcemaps: true,
82-
extractCss: false
82+
extractCss: false,
83+
vendorChunk: true
8384
},
8485
production: {
8586
environment: 'prod',
8687
outputHashing: 'all',
8788
sourcemaps: false,
8889
extractCss: true,
90+
vendorChunk: false,
8991
aot: true
9092
}
9193
};

packages/@angular/cli/models/webpack-configs/browser.ts

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export function getBrowserConfig(wco: WebpackConfigOptions) {
6060
baseHref: buildOptions.baseHref
6161
}),
6262
new webpack.optimize.CommonsChunkPlugin({
63+
name: 'main',
6364
async: 'common',
6465
children: true,
6566
minChunks: 2

packages/@angular/cli/models/webpack-configs/common.ts

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
113113
].concat(extraPlugins),
114114
node: {
115115
fs: 'empty',
116+
// `global` should be kept true, removing it resulted in a
117+
// massive size increase with NGO on AIO.
116118
global: true,
117119
crypto: 'empty',
118120
tls: 'empty',

packages/@angular/cli/models/webpack-configs/production.ts

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const getProdConfig = function (wco: WebpackConfigOptions) {
9898
'NODE_ENV': 'production'
9999
}),
100100
new (<any>webpack).HashedModuleIdsPlugin(),
101+
new (webpack.optimize as any).ModuleConcatenationPlugin(),
101102
new webpack.optimize.UglifyJsPlugin(<any>{
102103
mangle: { screw_ie8: true },
103104
compress: { screw_ie8: true, warnings: buildOptions.verbose },

packages/@angular/cli/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
"ember-cli-normalize-entity-name": "^1.0.0",
4242
"ember-cli-string-utils": "^1.0.0",
4343
"exports-loader": "^0.6.3",
44-
"extract-text-webpack-plugin": "^2.1.0",
44+
"extract-text-webpack-plugin": "3.0.0-beta.3",
4545
"file-loader": "^0.10.0",
4646
"fs-extra": "^3.0.1",
4747
"get-caller-file": "^1.0.0",
4848
"glob": "^7.0.3",
4949
"heimdalljs": "^0.2.4",
5050
"heimdalljs-logger": "^0.1.9",
51-
"html-webpack-plugin": "^2.19.0",
51+
"html-webpack-plugin": "^2.29.0",
5252
"inflection": "^1.7.0",
5353
"inquirer": "^3.0.0",
5454
"isbinaryfile": "^3.0.0",
@@ -83,8 +83,8 @@
8383
"typescript": ">=2.0.0 <2.4.0",
8484
"url-loader": "^0.5.7",
8585
"walk-sync": "^0.3.1",
86-
"webpack": "~2.4.0",
87-
"webpack-dev-middleware": "^1.10.2",
86+
"webpack": "~3.0.0",
87+
"webpack-dev-middleware": "^1.11.0",
8888
"webpack-dev-server": "~2.4.5",
8989
"webpack-merge": "^2.4.0",
9090
"zone.js": "^0.8.4"

packages/@angular/cli/tasks/eject.ts

+3
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ class JsonWebpackSerializer {
174174
case webpack.optimize.UglifyJsPlugin:
175175
this._addImport('webpack.optimize', 'UglifyJsPlugin');
176176
break;
177+
case (webpack.optimize as any).ModuleConcatenationPlugin:
178+
this._addImport('webpack.optimize', 'ModuleConcatenationPlugin');
179+
break;
177180
case angularCliPlugins.BaseHrefWebpackPlugin:
178181
case angularCliPlugins.SuppressExtractedTextChunksWebpackPlugin:
179182
this._addImport('@angular/cli/plugins/webpack', plugin.constructor.name);

tests/e2e/tests/build/chunk-hash.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ export default function() {
6161
`, '@angular/router'))
6262
.then(() => addImportToModule(
6363
'src/app/app.module.ts', 'ReactiveFormsModule', '@angular/forms'))
64-
.then(() => ng('build', '--prod'))
64+
.then(() => ng('build', '--output-hashing=all'))
6565
.then(() => {
6666
oldHashes = generateFileHashMap();
6767
})
68-
.then(() => ng('build', '--prod'))
68+
.then(() => ng('build', '--output-hashing=all'))
6969
.then(() => {
7070
newHashes = generateFileHashMap();
7171
})
@@ -74,16 +74,16 @@ export default function() {
7474
oldHashes = newHashes;
7575
})
7676
.then(() => writeFile('src/styles.css', 'body { background: blue; }'))
77-
.then(() => ng('build', '--prod'))
77+
.then(() => ng('build', '--output-hashing=all'))
7878
.then(() => {
7979
newHashes = generateFileHashMap();
8080
})
8181
.then(() => {
82-
validateHashes(oldHashes, newHashes, ['styles']);
82+
validateHashes(oldHashes, newHashes, ['inline', 'styles']);
8383
oldHashes = newHashes;
8484
})
8585
.then(() => writeFile('src/app/app.component.css', 'h1 { margin: 10px; }'))
86-
.then(() => ng('build', '--prod'))
86+
.then(() => ng('build', '--output-hashing=all'))
8787
.then(() => {
8888
newHashes = generateFileHashMap();
8989
})
@@ -93,7 +93,7 @@ export default function() {
9393
})
9494
.then(() => addImportToModule(
9595
'src/app/lazy/lazy.module.ts', 'ReactiveFormsModule', '@angular/forms'))
96-
.then(() => ng('build', '--prod'))
96+
.then(() => ng('build', '--output-hashing=all'))
9797
.then(() => {
9898
newHashes = generateFileHashMap();
9999
})

0 commit comments

Comments
 (0)