Skip to content

Commit 903a56e

Browse files
fix: support webpack@5 (#477)
1 parent 4498ed0 commit 903a56e

File tree

23 files changed

+282
-132
lines changed

23 files changed

+282
-132
lines changed

azure-pipelines.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ jobs:
5656
node-10-canary:
5757
node_version: ^10.13.0
5858
webpack_version: next
59-
continue_on_error: true
6059
steps:
6160
- task: NodeTool@0
6261
inputs:
@@ -78,7 +77,7 @@ jobs:
7877
displayName: 'Install dependencies'
7978
- script: npm i webpack@$(webpack_version)
8079
displayName: 'Install "webpack@$(webpack_version)"'
81-
- script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit" || $(continue_on_error)
80+
- script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit"
8281
displayName: 'Run tests with coverage'
8382
- task: PublishTestResults@2
8483
inputs:
@@ -114,7 +113,6 @@ jobs:
114113
node-10-canary:
115114
node_version: ^10.13.0
116115
webpack_version: next
117-
continue_on_error: true
118116
steps:
119117
- task: NodeTool@0
120118
inputs:
@@ -136,7 +134,7 @@ jobs:
136134
displayName: 'Install dependencies'
137135
- script: npm i webpack@$(webpack_version)
138136
displayName: 'Install "webpack@$(webpack_version)"'
139-
- script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit" || $(continue_on_error)
137+
- script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit"
140138
displayName: 'Run tests with coverage'
141139
- task: PublishTestResults@2
142140
inputs:
@@ -172,7 +170,6 @@ jobs:
172170
node-10-canary:
173171
node_version: ^10.13.0
174172
webpack_version: next
175-
continue_on_error: true
176173
steps:
177174
- script: 'git config --global core.autocrlf input'
178175
displayName: 'Config git core.autocrlf'
@@ -197,7 +194,7 @@ jobs:
197194
displayName: 'Install dependencies'
198195
- script: npm i webpack@$(webpack_version)
199196
displayName: 'Install "webpack@$(webpack_version)"'
200-
- script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit" || $(continue_on_error)
197+
- script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit"
201198
displayName: 'Run tests with coverage'
202199
- task: PublishTestResults@2
203200
inputs:

package-lock.json

Lines changed: 208 additions & 118 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
@@ -36,7 +36,7 @@
3636
"dist"
3737
],
3838
"peerDependencies": {
39-
"webpack": "^4.4.0"
39+
"webpack": "^4.4.0 || ^5.0.0"
4040
},
4141
"dependencies": {
4242
"loader-utils": "^1.1.0",
@@ -72,7 +72,7 @@
7272
"npm-run-all": "^4.1.5",
7373
"prettier": "^1.19.1",
7474
"standard-version": "^7.0.1",
75-
"webpack": "^4.41.3",
75+
"webpack": "^4.41.4",
7676
"webpack-cli": "^3.3.6",
7777
"webpack-dev-server": "^3.7.2"
7878
},

test/TestCases.test.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ function compareDirectory(actual, expected) {
2626
}
2727

2828
function compareWarning(actual, expectedFile) {
29-
if (!fs.existsSync(expectedFile)) return;
29+
if (!fs.existsSync(expectedFile)) {
30+
return;
31+
}
32+
33+
// eslint-disable-next-line global-require, import/no-dynamic-require
34+
const expected = require(expectedFile);
3035

31-
const expected = require(expectedFile); // eslint-disable-line global-require,import/no-dynamic-require
32-
expect(actual).toBe(expected);
36+
expect(actual.trim()).toBe(expected.trim());
3337
}
3438

3539
describe('TestCases', () => {
@@ -97,8 +101,19 @@ describe('TestCases', () => {
97101
}
98102

99103
const expectedDirectory = path.resolve(directoryForCase, 'expected');
104+
const expectedDirectoryByVersion = path.join(
105+
expectedDirectory,
106+
`webpack-${webpack.version[0]}`
107+
);
100108

101-
compareDirectory(outputDirectoryForCase, expectedDirectory);
109+
if (fs.existsSync(expectedDirectoryByVersion)) {
110+
compareDirectory(
111+
outputDirectoryForCase,
112+
expectedDirectoryByVersion
113+
);
114+
} else {
115+
compareDirectory(outputDirectoryForCase, expectedDirectory);
116+
}
102117

103118
const expectedWarning = path.resolve(directoryForCase, 'warnings.js');
104119
const actualWarning = stats.toString({

test/cases/composes-async/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
/* eslint-disable-next-line no-unused-expressions */
12
import(/* webpackChunkName: "async-1" */ './async-1.css');
3+
/* eslint-disable-next-line no-unused-expressions */
24
import(/* webpackChunkName: "async-2" */ './async-2.css');
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@import url(https://some/other/external/css);
2+
@import url(https://some/external/css);
3+
body {
4+
background: red;
5+
}
6+
7+
.c {
8+
background: red;
9+
}
10+
11+
.c {
12+
color: yellow;
13+
}
14+
15+
.b {
16+
background: red;
17+
}
18+
19+
.b {
20+
color: yellow;
21+
}
22+
23+
24+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/******/ (() => { // webpackBootstrap
2+
/******/ /************************************************************************/
3+
// extracted by mini-css-extract-plugin
4+
if(false) { var cssReload; }
5+
6+
/******/ })()
7+
;

0 commit comments

Comments
 (0)