Skip to content

Commit 18c9541

Browse files
committed
feat(@angular-devkit/build-webpack): support Webpack 5
The `@angular-devkit/build-webpack` package now officially supports Webpack 5. Webpack 4 support is temporarily maintained while the remainder of the tooling is transitioned.
1 parent a3ab2de commit 18c9541

File tree

4 files changed

+69
-6
lines changed

4 files changed

+69
-6
lines changed

packages/angular_devkit/build_webpack/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
},
1313
"devDependencies": {
1414
"@angular-devkit/core": "0.0.0",
15-
"node-fetch": "2.6.1"
15+
"node-fetch": "2.6.1",
16+
"webpack": "5.30.0"
1617
},
1718
"peerDependencies": {
18-
"webpack": "^4.6.0",
19+
"webpack": "^4.6.0 || ^5.30.0",
1920
"webpack-dev-server": "^3.1.4"
2021
}
2122
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import * as webpack from 'webpack';
9+
10+
// Webpack 5 transition support types
11+
declare module 'webpack' {
12+
export namespace compilation {
13+
export type Chunk = webpack.Chunk;
14+
export type Compilation = webpack.Compilation;
15+
}
16+
17+
export namespace Stats {
18+
export type ToJsonOutput = webpack.StatsCompilation;
19+
}
20+
}

packages/angular_devkit/build_webpack/src/webpack-dev-server/index.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,21 @@ export function runWebpackDevServer(
5252
config: WebpackDevServer.Configuration,
5353
) => {
5454
if (options.webpackDevServerFactory) {
55-
return new options.webpackDevServerFactory(webpack, config);
55+
// webpack-dev-server types currently do not support Webpack 5
56+
// tslint:disable-next-line: no-any
57+
return new options.webpackDevServerFactory(webpack as any, config);
5658
}
5759

58-
return new WebpackDevServer(webpack, config);
60+
// webpack-dev-server types currently do not support Webpack 5
61+
// tslint:disable-next-line: no-any
62+
return new WebpackDevServer(webpack as any, config);
5963
};
6064

6165
const log: WebpackLoggingCallback = options.logging
6266
|| ((stats, config) => context.logger.info(stats.toString(config.stats)));
6367

64-
const devServerConfig = options.devServerConfig || config.devServer || {};
68+
// tslint:disable-next-line: no-any
69+
const devServerConfig = options.devServerConfig || (config as any).devServer || {};
6570
if (devServerConfig.stats) {
6671
config.stats = devServerConfig.stats;
6772
}
@@ -110,7 +115,10 @@ export function runWebpackDevServer(
110115
);
111116

112117
// Teardown logic. Close the server when unsubscribed from.
113-
return () => server.close();
118+
return (() => {
119+
server.close();
120+
webpackCompiler.close?.(() => {});
121+
});
114122
})),
115123
);
116124
}

yarn.lock

+34
Original file line numberDiff line numberDiff line change
@@ -5384,6 +5384,11 @@ es-module-lexer@^0.3.26:
53845384
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.3.26.tgz#7b507044e97d5b03b01d4392c74ffeb9c177a83b"
53855385
integrity sha512-Va0Q/xqtrss45hWzP8CZJwzGSZJjDM5/MJRE3IXXnUCcVLElR9BRaE9F62BopysASyc4nM3uwhSW7FFB9nlWAA==
53865386

5387+
es-module-lexer@^0.4.0:
5388+
version "0.4.1"
5389+
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.4.1.tgz#dda8c6a14d8f340a24e34331e0fab0cb50438e0e"
5390+
integrity sha512-ooYciCUtfw6/d2w56UVeqHPcoCFAiJdz5XOkYpv/Txl1HMUozpXjz/2RIQgqwKdXNDPSF1W7mJCFse3G+HDyAA==
5391+
53875392
es-to-primitive@^1.2.1:
53885393
version "1.2.1"
53895394
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a"
@@ -13393,6 +13398,35 @@ webpack@5.21.2:
1339313398
watchpack "^2.0.0"
1339413399
webpack-sources "^2.1.1"
1339513400

13401+
webpack@5.30.0:
13402+
version "5.30.0"
13403+
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.30.0.tgz#07d87c182a060e0c2491062f3dc0edc85a29d884"
13404+
integrity sha512-Zr9NIri5yzpfmaMea2lSMV1UygbW0zQsSlGLMgKUm63ACXg6alhd1u4v5UBSBjzYKXJN6BNMGVM7w165e7NxYA==
13405+
dependencies:
13406+
"@types/eslint-scope" "^3.7.0"
13407+
"@types/estree" "^0.0.46"
13408+
"@webassemblyjs/ast" "1.11.0"
13409+
"@webassemblyjs/wasm-edit" "1.11.0"
13410+
"@webassemblyjs/wasm-parser" "1.11.0"
13411+
acorn "^8.0.4"
13412+
browserslist "^4.14.5"
13413+
chrome-trace-event "^1.0.2"
13414+
enhanced-resolve "^5.7.0"
13415+
es-module-lexer "^0.4.0"
13416+
eslint-scope "^5.1.1"
13417+
events "^3.2.0"
13418+
glob-to-regexp "^0.4.1"
13419+
graceful-fs "^4.2.4"
13420+
json-parse-better-errors "^1.0.2"
13421+
loader-runner "^4.2.0"
13422+
mime-types "^2.1.27"
13423+
neo-async "^2.6.2"
13424+
schema-utils "^3.0.0"
13425+
tapable "^2.1.1"
13426+
terser-webpack-plugin "^5.1.1"
13427+
watchpack "^2.0.0"
13428+
webpack-sources "^2.1.1"
13429+
1339613430
websocket-driver@>=0.5.1, websocket-driver@^0.7.4:
1339713431
version "0.7.4"
1339813432
resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760"

0 commit comments

Comments
 (0)