Skip to content

Commit 5c9b897

Browse files
authored
fix: Deprecation of loader options in webpack 5 (DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING) (#47)
1 parent 3507d8d commit 5c9b897

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module.exports = (api, options) => {
7979
chain.module.rule('vue')
8080
.use('vue-auto-import-quasar')
8181
.loader(path.join(__dirname, 'lib/loader.vue.auto-import-quasar.js'))
82-
.options(strategy)
82+
.options({ strategy })
8383
.before('cache-loader')
8484

8585
chain.module.rule('js-transform-quasar-imports')

lib/loader.vue.auto-import-quasar.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const importTransformation = getDevlandFile('quasar/dist/transforms/import-trans
66
const runtimePath = require.resolve('./runtime.auto-import.js')
77

88
const compRegex = {
9-
'?kebab': new RegExp(autoImportData.regex.kebabComponents || autoImportData.regex.components, 'g'),
10-
'?pascal': new RegExp(autoImportData.regex.pascalComponents || autoImportData.regex.components, 'g'),
11-
'?combined': new RegExp(autoImportData.regex.components, 'g')
9+
'kebab': new RegExp(autoImportData.regex.kebabComponents || autoImportData.regex.components, 'g'),
10+
'pascal': new RegExp(autoImportData.regex.pascalComponents || autoImportData.regex.components, 'g'),
11+
'combined': new RegExp(autoImportData.regex.components, 'g')
1212
}
1313

1414
const dirRegex = new RegExp(autoImportData.regex.directives, 'g')
@@ -20,7 +20,10 @@ function transform (itemArray) {
2020
}
2121

2222
function extract (content, ctx) {
23-
let comp = content.match(compRegex[ctx.query])
23+
// Use webpack v5 getOptions or fallback to ctx.query for webpack v4
24+
const { strategy } = ctx.getOptions ? ctx.getOptions() : ctx.query
25+
26+
let comp = content.match(compRegex[strategy])
2427
let dir = content.match(dirRegex)
2528

2629
if (comp === null && dir === null) {
@@ -35,11 +38,11 @@ function extract (content, ctx) {
3538
comp = Array.from(new Set(comp))
3639

3740
// map comp names only if not pascal-case already
38-
if (ctx.query !== '?pascal') {
41+
if (strategy !== 'pascal') {
3942
comp = comp.map(name => autoImportData.importName[name])
4043
}
4144

42-
if (ctx.query === '?combined') {
45+
if (strategy === 'combined') {
4346
// could have been transformed QIcon and q-icon too,
4447
// so avoid duplicates
4548
comp = Array.from(new Set(comp))

0 commit comments

Comments
 (0)