Unverified Commit 84c34a40 authored by Haoqun Jiang's avatar Haoqun Jiang Committed by GitHub

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
parent 111240c8
...@@ -27,3 +27,7 @@ jobs: ...@@ -27,3 +27,7 @@ jobs:
# run tests! # run tests!
- run: yarn test - run: yarn test
- run: npx json -f package.json -I -e "this.resolutions = {}, this.resolutions.webpack = '^5.0.0-0', this.devDependencies.webpack = '^5.0.0-0' "
- run: yarn install
- run: yarn test
...@@ -128,8 +128,9 @@ class VueLoaderPlugin { ...@@ -128,8 +128,9 @@ class VueLoaderPlugin {
} }
} }
let uid = 0
function cloneRule (rawRule, refs) { function cloneRule (rawRule, refs) {
const rules = ruleSetCompiler.compileRules('ruleSet', [{ const rules = ruleSetCompiler.compileRules(`clonedRuleSet-${++uid}`, [{
rules: [rawRule] rules: [rawRule]
}], refs) }], refs)
let currentResource let currentResource
......
...@@ -144,3 +144,33 @@ test('script import', done => { ...@@ -144,3 +144,33 @@ test('script import', done => {
done() done()
}) })
}) })
// #1620
test('cloned rules should not intefere with each other', done => {
mockBundleAndRun({
entry: 'basic.vue',
module: {
rules: [{
test: /\.js$/,
use: [
{
loader: 'babel-loader',
options: {}
}
]
}, {
test: /\.some-random-extension$/,
use: [
{
loader: 'css-loader',
options: {
url: true
}
}
]
}]
}
}, () => {
done()
})
})
...@@ -39,7 +39,11 @@ const baseConfig = { ...@@ -39,7 +39,11 @@ const baseConfig = {
plugins: [ plugins: [
new VueLoaderPlugin(), new VueLoaderPlugin(),
new webpack.optimize.ModuleConcatenationPlugin() new webpack.optimize.ModuleConcatenationPlugin()
] ],
// https://github.com/webpack/webpack/issues/10542
optimization: {
usedExports: false
}
} }
function genId (file) { function genId (file) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment