Skip to content

Commit b94289c

Browse files
committed
fix: fix webpack 5.48 compatibility
Fixes #1859
1 parent 58e6188 commit b94289c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/pluginWebpack5.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@ const NS = 'vue-loader'
88
const NormalModule = require('webpack/lib/NormalModule')
99
const BasicEffectRulePlugin = require('webpack/lib/rules/BasicEffectRulePlugin')
1010
const BasicMatcherRulePlugin = require('webpack/lib/rules/BasicMatcherRulePlugin')
11-
const DescriptionDataMatcherRulePlugin = require('webpack/lib/rules/DescriptionDataMatcherRulePlugin')
1211
const UseEffectRulePlugin = require('webpack/lib/rules/UseEffectRulePlugin')
1312
const RuleSetCompiler = require('webpack/lib/rules/RuleSetCompiler') as RuleSetCompiler
1413

14+
let objectMatcherRulePlugins = []
15+
try {
16+
const ObjectMatcherRulePlugin = require('webpack/lib/rules/ObjectMatcherRulePlugin')
17+
objectMatcherRulePlugins.push(
18+
new ObjectMatcherRulePlugin('assert', 'assertions'),
19+
new ObjectMatcherRulePlugin('descriptionData')
20+
)
21+
} catch (e) {
22+
const DescriptionDataMatcherRulePlugin = require('webpack/lib/rules/DescriptionDataMatcherRulePlugin')
23+
objectMatcherRulePlugins.push(new DescriptionDataMatcherRulePlugin())
24+
}
25+
1526
type RawRule = RuleSetRule
1627

1728
// webpack 5 doesn't export the internal Rule types so we have to shim it here
@@ -74,7 +85,7 @@ const ruleSetCompiler = new RuleSetCompiler([
7485
new BasicMatcherRulePlugin('realResource'),
7586
new BasicMatcherRulePlugin('issuer'),
7687
new BasicMatcherRulePlugin('compiler'),
77-
new DescriptionDataMatcherRulePlugin(),
88+
...objectMatcherRulePlugins,
7889
new BasicEffectRulePlugin('type'),
7990
new BasicEffectRulePlugin('sideEffects'),
8091
new BasicEffectRulePlugin('parser'),

0 commit comments

Comments
 (0)