Skip to content

Commit 080de04

Browse files
committed
feat(@angular-devkit/build-angular): use webpack 5
1 parent 2326850 commit 080de04

File tree

7 files changed

+79
-497
lines changed

7 files changed

+79
-497
lines changed

packages/angular_devkit/build_angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"stylus-loader": "3.0.2",
4747
"tree-kill": "1.2.1",
4848
"terser-webpack-plugin": "1.2.0",
49-
"webpack": "4.28.2",
49+
"webpack": "5.0.0-alpha.3",
5050
"webpack-dev-middleware": "3.4.0",
5151
"webpack-dev-server": "3.1.14",
5252
"webpack-merge": "4.1.5",

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/browser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ export function getBrowserConfig(wco: WebpackConfigOptions) {
108108
name: 'vendor',
109109
chunks: 'initial',
110110
enforce: true,
111-
test: (module: { nameForCondition?: Function }, chunks: Array<{ name: string }>) => {
111+
test: (module: any) => {
112112
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
113+
const chunks = module.getChunks();
113114

114115
return /[\\/]node_modules[\\/]/.test(moduleName)
115116
&& !chunks.some(({ name }) => name === 'polyfills'

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import * as CopyWebpackPlugin from 'copy-webpack-plugin';
99
import * as path from 'path';
10-
import { HashedModuleIdsPlugin, debug } from 'webpack';
10+
import { ids, debug } from 'webpack';
1111
import { AssetPatternObject } from '../../../browser/schema';
1212
import { BundleBudgetPlugin } from '../../plugins/bundle-budget';
1313
import { CleanCssWebpackPlugin } from '../../plugins/cleancss-webpack-plugin';
@@ -154,9 +154,11 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
154154
}
155155

156156
if (buildOptions.showCircularDependencies) {
157-
extraPlugins.push(new CircularDependencyPlugin({
158-
exclude: /([\\\/]node_modules[\\\/])|(ngfactory\.js$)/,
159-
}));
157+
// Breaks with Webpack 5:
158+
// Error: module property was removed from Dependency (use compilation.moduleGraph.getModule(dependency) instead)
159+
// extraPlugins.push(new CircularDependencyPlugin({
160+
// exclude: /([\\\/]node_modules[\\\/])|(ngfactory\.js$)/,
161+
// }));
160162
}
161163

162164
if (buildOptions.statsJson) {
@@ -306,6 +308,8 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
306308
// Mark files inside `@angular/core` as using SystemJS style dynamic imports.
307309
// Removing this will cause deprecation warnings to appear.
308310
test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/,
311+
// Seems like this doesn't hide the warning anymore. Might need to use a filter on the
312+
// warnings instead.
309313
parser: { system: true },
310314
},
311315
{
@@ -323,7 +327,7 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
323327
optimization: {
324328
noEmitOnErrors: true,
325329
minimizer: [
326-
new HashedModuleIdsPlugin(),
330+
new ids.HashedModuleIdsPlugin(),
327331
// TODO: check with Mike what this feature needs.
328332
new BundleBudgetPlugin({ budgets: buildOptions.budgets }),
329333
...extraMinimizers,

packages/angular_devkit/build_angular/src/angular-cli-files/utilities/stats.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ export function statsWarningsToString(json: any, statsConfig: any) {
6969
const rs = (x: string) => colors ? reset(x) : x;
7070
const y = (x: string) => colors ? bold(yellow(x)) : x;
7171

72-
return rs('\n' + json.warnings.map((warning: any) => y(`WARNING in ${warning}`)).join('\n\n'));
72+
return rs('\n' + json.warnings.map((warning: any) => y(`WARNING in ${warning.message}`)).join('\n\n'));
7373
}
7474

7575
export function statsErrorsToString(json: any, statsConfig: any) {
7676
const colors = statsConfig.colors;
7777
const rs = (x: string) => colors ? reset(x) : x;
7878
const r = (x: string) => colors ? bold(red(x)) : x;
7979

80-
return rs('\n' + json.errors.map((error: any) => r(`ERROR in ${error}`)).join('\n'));
80+
return rs('\n' + json.errors.map((error: any) => r(`ERROR in ${error.message}`)).join('\n'));
8181
}

packages/angular_devkit/build_webpack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"webpack-dev-server": "^3.1.4"
1616
},
1717
"devDependencies": {
18-
"webpack": "^4.6.0",
18+
"webpack": "5.0.0-alpha.3",
1919
"webpack-dev-server": "^3.1.4"
2020
}
2121
}

packages/ngtools/webpack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636
"@angular/compiler": "^7.2.0-rc.0",
3737
"@angular/compiler-cli": "^7.2.0-rc.0",
3838
"typescript": "~3.2.2",
39-
"webpack": "^4.0.0"
39+
"webpack": "5.0.0-alpha.3"
4040
}
4141
}

0 commit comments

Comments
 (0)