Skip to content

Commit 80c3edc

Browse files
clydinfilipesilva
authored andcommitted
feat(@angular/cli): update webpack-dev-server to 3.0
1 parent af0080d commit 80c3edc

18 files changed

+271
-74
lines changed

package-lock.json

Lines changed: 232 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@
9696
"uglifyjs-webpack-plugin": "^1.2.2",
9797
"url-loader": "^0.6.2",
9898
"webpack": "~4.0.0",
99-
"webpack-dev-middleware": "~1.12.0",
100-
"webpack-dev-server": "~2.11.0",
99+
"webpack-dev-middleware": "^2.0.6",
100+
"webpack-dev-server": "^3.0.1-beta.0",
101101
"webpack-merge": "^4.1.2",
102102
"webpack-sources": "^1.1.0",
103103
"webpack-subresource-integrity": "^1.0.1"

packages/@angular/cli/custom-typings.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ interface IWebpackDevServerConfigurationOptions {
1515
};
1616
publicPath?: string;
1717
headers?: { [key: string]: string };
18-
stats?: { [key: string]: boolean } | string;
19-
inline: boolean;
18+
stats?: { [key: string]: boolean } | string | boolean;
19+
inline?: boolean;
2020
https?: boolean;
2121
key?: string;
2222
cert?: string;

packages/@angular/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
"uglifyjs-webpack-plugin": "^1.2.2",
8181
"url-loader": "^0.6.2",
8282
"webpack": "~4.0.0",
83-
"webpack-dev-middleware": "~1.12.0",
84-
"webpack-dev-server": "~2.11.0",
83+
"webpack-dev-middleware": "^2.0.6",
84+
"webpack-dev-server": "^3.0.1-beta.0",
8585
"webpack-merge": "^4.1.2",
8686
"webpack-sources": "^1.1.0",
8787
"webpack-subresource-integrity": "^1.0.1"

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export default Task.extend({
156156
// we can override the file watcher instead.
157157
webpackConfig.plugins.unshift({
158158
apply: (compiler: any) => {
159-
compiler.plugin('after-environment', () => {
159+
compiler.hooks.afterEnvironment.tap('angular-cli', () => {
160160
compiler.watchFileSystem = { watch: () => { } };
161161
});
162162
}
@@ -166,7 +166,7 @@ export default Task.extend({
166166
webpackCompiler = webpack(webpackConfig);
167167

168168
if (rebuildDoneCb) {
169-
webpackCompiler.plugin('done', rebuildDoneCb);
169+
webpackCompiler.hooks.done.tap('angular-cli', rebuildDoneCb);
170170
}
171171

172172
const statsConfig = getWebpackStatsConfig(serveTaskOptions.verbose);
@@ -222,8 +222,7 @@ export default Task.extend({
222222
disableDotRule: true,
223223
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml']
224224
},
225-
stats: serveTaskOptions.verbose ? statsConfig : 'none',
226-
inline: true,
225+
stats: serveTaskOptions.verbose ? statsConfig : false,
227226
proxy: proxyConfig,
228227
compress: serveTaskOptions.target === 'production',
229228
watchOptions: {
@@ -237,16 +236,15 @@ export default Task.extend({
237236
contentBase: false,
238237
public: serveTaskOptions.publicHost,
239238
disableHostCheck: serveTaskOptions.disableHostCheck,
240-
publicPath: servePath
239+
publicPath: servePath,
240+
hot: serveTaskOptions.hmr,
241241
};
242242

243243
if (sslKey != null && sslCert != null) {
244244
webpackDevServerConfiguration.key = sslKey;
245245
webpackDevServerConfiguration.cert = sslCert;
246246
}
247247

248-
webpackDevServerConfiguration.hot = serveTaskOptions.hmr;
249-
250248
if (serveTaskOptions.target === 'production') {
251249
ui.writeLine(chalk.red(stripIndents`
252250
****************************************************************************************
@@ -266,8 +264,9 @@ export default Task.extend({
266264
`));
267265

268266
const server = new WebpackDevServer(webpackCompiler, webpackDevServerConfiguration);
269-
if (!serveTaskOptions.verbose) {
270-
webpackCompiler.plugin('done', (stats: any) => {
267+
268+
webpackCompiler.hooks.done.tap('angular-cli', (stats: webpack.Stats) => {
269+
if (!serveTaskOptions.verbose) {
271270
const json = stats.toJson(statsConfig);
272271
this.ui.writeLine(statsToString(json, statsConfig));
273272
if (stats.hasWarnings()) {
@@ -276,21 +275,23 @@ export default Task.extend({
276275
if (stats.hasErrors()) {
277276
this.ui.writeError(statsErrorsToString(json, statsConfig));
278277
}
279-
});
280-
}
278+
}
279+
280+
if (serveTaskOptions.open) {
281+
opn(serverAddress + servePath);
282+
}
283+
});
281284

282285
return new Promise((_resolve, reject) => {
283286
const httpServer = server.listen(
284287
serveTaskOptions.port,
285288
serveTaskOptions.host,
286-
(err: any, _stats: any) => {
289+
(err: any) => {
287290
if (err) {
288-
return reject(err);
289-
}
290-
if (serveTaskOptions.open) {
291-
opn(serverAddress + servePath);
291+
reject(err);
292292
}
293-
});
293+
},
294+
);
294295
// Node 8 has a keepAliveTimeout bug which doesn't respect active connections.
295296
// Connections will end after ~5 seconds (arbitrary), often not letting the full download
296297
// of large pieces of content, such as a vendor javascript file. This results in browsers
@@ -304,9 +305,8 @@ export default Task.extend({
304305
})
305306
.catch((err: Error) => {
306307
if (err) {
307-
this.ui.writeError('\nAn error occured during the build:\n' + ((err && err.stack) || err));
308+
this.ui.writeError('\nAn error occured during the build:\n' + (err.stack || err));
308309
}
309-
throw err;
310310
});
311311
}
312312
});

tests/e2e/tests/basic/e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function () {
5858
})
5959
// Should run side-by-side with `ng serve`
6060
.then(() => execAndWaitForOutputToMatch('ng', ['serve'],
61-
/webpack: Compiled successfully./))
61+
/: Compiled successfully./))
6262
.then(() => ng('e2e'))
6363
.then(() => killAllProcesses(), (err: any) => {
6464
killAllProcesses();

tests/e2e/tests/basic/rebuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {wait} from '../../utils/utils';
99
import {request} from '../../utils/http';
1010
import {getGlobalVariable} from '../../utils/env';
1111

12-
const validBundleRegEx = /webpack: bundle is now VALID|webpack: Compiled successfully./;
12+
const validBundleRegEx = /: Compiled successfully./;
1313

1414
export default function() {
1515
if (process.platform.startsWith('win')) {

tests/e2e/tests/build/aot/aot-rebuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { getGlobalVariable } from '../../../utils/env';
88
import { request } from '../../../utils/http';
99
import { wait } from '../../../utils/utils';
1010

11-
const validBundleRegEx = /webpack: bundle is now VALID|webpack: Compiled successfully./;
11+
const validBundleRegEx = /: Compiled successfully./;
1212

1313
export default function () {
1414
if (process.platform.startsWith('win')) {

tests/e2e/tests/build/eval-sourcemap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function() {
1010

1111
return Promise.resolve()
1212
// Check that ng serve has eval sourcemaps by default.
13-
.then(() => execAndWaitForOutputToMatch('ng', ['serve'], /webpack: Compiled successfully/))
13+
.then(() => execAndWaitForOutputToMatch('ng', ['serve'], /: Compiled successfully/))
1414
.then((output) => {
1515
const stdout = output.stdout;
1616
if (/\.js\.map/.test(stdout)) {

tests/e2e/tests/build/poll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import {appendToFile} from '../../utils/fs';
77
import {expectToFail, wait} from '../../utils/utils';
88

9-
const webpackGoodRegEx = /webpack: Compiled successfully./;
9+
const webpackGoodRegEx = /: Compiled successfully./;
1010

1111
export default function() {
1212

0 commit comments

Comments
 (0)