Skip to content

Commit 84c34a4

Browse files
authored
fix: ensure unique ident when cloning rules, fix webpack 5 compatibility (#1653)
* chore: lockfile maintenance * chore: update memfs to ^3.1.2 Fixes a bug in `mkdir('/')`, which causes tests fail to run in webpack 5 * test: setup webpack 5 test * fix: fix webpack 5 compatibility and add test for it * ci: fix yaml grammar
1 parent 111240c commit 84c34a4

File tree

6 files changed

+257
-260
lines changed

6 files changed

+257
-260
lines changed

Diff for: .circleci/config.yml

+4
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ jobs:
2727

2828
# run tests!
2929
- run: yarn test
30+
31+
- run: npx json -f package.json -I -e "this.resolutions = {}, this.resolutions.webpack = '^5.0.0-0', this.devDependencies.webpack = '^5.0.0-0' "
32+
- run: yarn install
33+
- run: yarn test

Diff for: lib/plugin-webpack5.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ class VueLoaderPlugin {
128128
}
129129
}
130130

131+
let uid = 0
131132
function cloneRule (rawRule, refs) {
132-
const rules = ruleSetCompiler.compileRules('ruleSet', [{
133+
const rules = ruleSetCompiler.compileRules(`clonedRuleSet-${++uid}`, [{
133134
rules: [rawRule]
134135
}], refs)
135136
let currentResource

Diff for: package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@
6666
"eslint": "^4.19.0",
6767
"eslint-plugin-vue-libs": "^2.1.0",
6868
"file-loader": "^1.1.11",
69-
"html-webpack-plugin": "^3.1.0",
69+
"html-webpack-plugin": "4.0.0-beta.14",
7070
"javascript-stringify": "^1.6.0",
7171
"jest": "^23.5.0",
7272
"jsdom": "^11.6.2",
73+
"json": "^9.0.6",
7374
"lint-staged": "^7.0.0",
7475
"markdown-loader": "^2.0.2",
75-
"memfs": "^3.0.3",
76+
"memfs": "^3.1.2",
7677
"mini-css-extract-plugin": "^0.4.1",
7778
"node-sass": "^4.7.2",
7879
"normalize-newline": "^3.0.0",

Diff for: test/core.spec.js

+30
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,33 @@ test('script import', done => {
144144
done()
145145
})
146146
})
147+
148+
// #1620
149+
test('cloned rules should not intefere with each other', done => {
150+
mockBundleAndRun({
151+
entry: 'basic.vue',
152+
module: {
153+
rules: [{
154+
test: /\.js$/,
155+
use: [
156+
{
157+
loader: 'babel-loader',
158+
options: {}
159+
}
160+
]
161+
}, {
162+
test: /\.some-random-extension$/,
163+
use: [
164+
{
165+
loader: 'css-loader',
166+
options: {
167+
url: true
168+
}
169+
}
170+
]
171+
}]
172+
}
173+
}, () => {
174+
done()
175+
})
176+
})

Diff for: test/utils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ const baseConfig = {
3939
plugins: [
4040
new VueLoaderPlugin(),
4141
new webpack.optimize.ModuleConcatenationPlugin()
42-
]
42+
],
43+
// https://github.com/webpack/webpack/issues/10542
44+
optimization: {
45+
usedExports: false
46+
}
4347
}
4448

4549
function genId (file) {

0 commit comments

Comments
 (0)