Skip to content

Ensure unique ident when cloning rules, fix webpack 5 compatibility #1653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading