Skip to content

Commit 22d4663

Browse files
committed
feat(@angular/cli): add scope hoisting
See the following links for details on scope hoisting: https://medium.com/webpack/webpack-freelancing-log-book-week-5-7-4764be3266f5 https://medium.com/webpack/webpack-freelancing-log-book-week-8-e73811deb412 Node's global and process were also removed, since they seemed to affect optimization gains.
1 parent 01cbf65 commit 22d4663

File tree

8 files changed

+17
-11
lines changed

8 files changed

+17
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"typescript": "~2.3.1",
9696
"url-loader": "^0.5.7",
9797
"walk-sync": "^0.3.1",
98-
"webpack": "~2.4.0",
98+
"webpack": "3.0.0-rc.1",
9999
"webpack-dev-middleware": "^1.10.2",
100100
"webpack-dev-server": "~2.4.5",
101101
"webpack-merge": "^2.4.0",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ export class NgCliWebpackConfig {
8686
outputHashing: 'all',
8787
sourcemaps: false,
8888
extractCss: true,
89-
aot: true
89+
aot: true,
90+
vendorChunk: false
9091
}
9192
};
9293

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
9898
].concat(extraPlugins),
9999
node: {
100100
fs: 'empty',
101-
global: true,
101+
global: false,
102102
crypto: 'empty',
103103
tls: 'empty',
104104
net: 'empty',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const getProdConfig = function (wco: WebpackConfigOptions) {
9494
'NODE_ENV': 'production'
9595
}),
9696
new (<any>webpack).HashedModuleIdsPlugin(),
97+
new (webpack.optimize as any).ModuleConcatenationPlugin(),
9798
new webpack.optimize.UglifyJsPlugin(<any>{
9899
mangle: { screw_ie8: true },
99100
compress: { screw_ie8: true, warnings: buildOptions.verbose },

packages/@angular/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"typescript": ">=2.0.0 <2.4.0",
8181
"url-loader": "^0.5.7",
8282
"walk-sync": "^0.3.1",
83-
"webpack": "~2.4.0",
83+
"webpack": "3.0.0-rc.1",
8484
"webpack-dev-middleware": "^1.10.2",
8585
"webpack-dev-server": "~2.4.5",
8686
"webpack-merge": "^2.4.0",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ export default Task.extend({
9494
`);
9595
}
9696
}
97+
// Live reload an additional entry point.
9798
if (!webpackConfig.entry.main) { webpackConfig.entry.main = []; }
9899
webpackConfig.entry.main.unshift(...entryPoints);
100+
// Live reload required the node `global` to be set to true.
101+
if (!webpackConfig.node) { webpackConfig.node = {}; }
102+
webpackConfig.node.global = true;
99103
} else if (serveTaskOptions.hmr) {
100104
ui.writeLine(chalk.yellow('Live reload is disabled. HMR option ignored.'));
101105
}

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

Lines changed: 6 additions & 6 deletions
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
})

tests/e2e/tests/test/test-assets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function () {
1919
// Not using `async()` in tests as it seemed to swallow `fetch()` errors
2020
'src/app/app.component.spec.ts': stripIndent`
2121
describe('Test Runner', () => {
22-
const fetch = global['fetch'];
22+
const fetch = window['fetch'];
2323
it('should serve files in assets folder', (done) => {
2424
fetch('/assets/file.txt')
2525
.then(response => response.text())

0 commit comments

Comments
 (0)