Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: ensure unique ident when cloning rules, fix webpack 5 compatib…
…ility (#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
  • Loading branch information
sodatea committed Mar 19, 2020
1 parent 111240c commit 84c34a4
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 260 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Expand Up @@ -27,3 +27,7 @@ jobs:

# run tests!
- 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
3 changes: 2 additions & 1 deletion lib/plugin-webpack5.js
Expand Up @@ -128,8 +128,9 @@ class VueLoaderPlugin {
}
}

let uid = 0
function cloneRule (rawRule, refs) {
const rules = ruleSetCompiler.compileRules('ruleSet', [{
const rules = ruleSetCompiler.compileRules(`clonedRuleSet-${++uid}`, [{
rules: [rawRule]
}], refs)
let currentResource
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -66,13 +66,14 @@
"eslint": "^4.19.0",
"eslint-plugin-vue-libs": "^2.1.0",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.1.0",
"html-webpack-plugin": "4.0.0-beta.14",
"javascript-stringify": "^1.6.0",
"jest": "^23.5.0",
"jsdom": "^11.6.2",
"json": "^9.0.6",
"lint-staged": "^7.0.0",
"markdown-loader": "^2.0.2",
"memfs": "^3.0.3",
"memfs": "^3.1.2",
"mini-css-extract-plugin": "^0.4.1",
"node-sass": "^4.7.2",
"normalize-newline": "^3.0.0",
Expand Down
30 changes: 30 additions & 0 deletions test/core.spec.js
Expand Up @@ -144,3 +144,33 @@ test('script import', 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()
})
})
6 changes: 5 additions & 1 deletion test/utils.js
Expand Up @@ -39,7 +39,11 @@ const baseConfig = {
plugins: [
new VueLoaderPlugin(),
new webpack.optimize.ModuleConcatenationPlugin()
]
],
// https://github.com/webpack/webpack/issues/10542
optimization: {
usedExports: false
}
}

function genId (file) {
Expand Down

0 comments on commit 84c34a4

Please sign in to comment.