Skip to content

Commit cbb18c8

Browse files
authored
webpack v5 compatibility (#2641)
* WIP webpack v5 migration * Linting * WIP again * Linting * Remove all: false * webpack dep bump * InjectManifest remediation * Linting. * Require 4.40 * Still WIP * WIP * Redo the asset/chunk mapping * Fixed some test cases * Another test fix * Get assets from child compilations * Tests pass * Re-arranged some thing. * Re-arranging things * Good webpack v4/v5 testing setup * Review feedback
1 parent ff9d868 commit cbb18c8

20 files changed

+4470
-2688
lines changed

Diff for: gulp-tasks/test-node.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ async function runNodeTestsWithEnv(testGroup, nodeEnv) {
5656

5757
const packagesToTest = glob.sync(`test/${testGroup}/node`, globConfig);
5858
for (const packageToTest of packagesToTest) {
59-
await runNodeTestSuite(packageToTest, nodeEnv);
59+
// Hardcode special logic for webpack v4 and v5 tests, which need to
60+
// be run in separate processes.
61+
if (packageToTest.includes('workbox-webpack-plugin')) {
62+
await runNodeTestSuite(`${packageToTest}/v4`, nodeEnv);
63+
await runNodeTestSuite(`${packageToTest}/v5`, nodeEnv);
64+
} else {
65+
await runNodeTestSuite(packageToTest, nodeEnv);
66+
}
6067
}
6168
}
6269

Diff for: infra/testing/webpack-build-check.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
https://opensource.org/licenses/MIT.
77
*/
88

9+
function joinMessages(errorsOrWarnings) {
10+
if ('message' in errorsOrWarnings[0]) {
11+
return errorsOrWarnings.map((item) => item.message).join('\n');
12+
} else {
13+
return errorsOrWarnings.join('\n');
14+
}
15+
}
916

1017
module.exports = (webpackError, stats) => {
1118
if (webpackError) {
@@ -15,10 +22,10 @@ module.exports = (webpackError, stats) => {
1522
const statsJson = stats.toJson('verbose');
1623

1724
if (statsJson.errors.length > 0) {
18-
throw new Error(statsJson.errors.join('\n'));
25+
throw new Error(joinMessages(statsJson.errors));
1926
}
2027

2128
if (statsJson.warnings.length > 0) {
22-
throw new Error(statsJson.warnings.join('\n'));
29+
throw new Error(joinMessages(statsJson.warnings));
2330
}
2431
};

Diff for: package-lock.json

+1,039-622
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@rollup/plugin-multi-entry": "^4.0.0",
4848
"@rollup/plugin-node-resolve": "^9.0.0",
4949
"@rollup/plugin-replace": "^2.3.3",
50+
"@types/estree": "0.0.45",
5051
"@typescript-eslint/eslint-plugin": "^2.30.0",
5152
"@typescript-eslint/parser": "^2.30.0",
5253
"acorn": "^8.0.1",
@@ -76,14 +77,15 @@
7677
"globby": "^11.0.1",
7778
"gulp": "^4.0.2",
7879
"gzip-size": "^5.1.1",
79-
"html-webpack-plugin": "^4.3.0",
80+
"html-webpack-plugin": "^4.5.0",
8081
"husky": "^4.2.5",
8182
"jsdoc": "^3.6.5",
8283
"jsdoc-baseline": "^0.1.5",
8384
"lerna": "^3.22.1",
8485
"memory-fs": "^0.5.0",
8586
"minimist": "^1.2.5",
8687
"mocha": "^8.1.1",
88+
"module-alias": "^2.2.2",
8789
"nunjucks": "^3.2.2",
8890
"nyc": "^15.1.0",
8991
"proxyquire": "^2.1.3",
@@ -99,7 +101,8 @@
99101
"tempy": "^0.6.0",
100102
"typescript": "^3.9.7",
101103
"upath": "^1.2.0",
102-
"webpack": "^4.44.1",
104+
"webpack-v4": "npm:webpack@^4.44.2",
105+
"webpack-v5": "npm:webpack@^5.0.0",
103106
"worker-plugin": "^5.0.0"
104107
}
105108
}

0 commit comments

Comments
 (0)