Skip to content

Commit

Permalink
fix: fix webpack 5.48 compatibility
Browse files Browse the repository at this point in the history
Fixes #1859
  • Loading branch information
sodatea committed Aug 2, 2021
1 parent 58e6188 commit b94289c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/pluginWebpack5.ts
Expand Up @@ -8,10 +8,21 @@ const NS = 'vue-loader'
const NormalModule = require('webpack/lib/NormalModule')
const BasicEffectRulePlugin = require('webpack/lib/rules/BasicEffectRulePlugin')
const BasicMatcherRulePlugin = require('webpack/lib/rules/BasicMatcherRulePlugin')
const DescriptionDataMatcherRulePlugin = require('webpack/lib/rules/DescriptionDataMatcherRulePlugin')
const UseEffectRulePlugin = require('webpack/lib/rules/UseEffectRulePlugin')
const RuleSetCompiler = require('webpack/lib/rules/RuleSetCompiler') as RuleSetCompiler

let objectMatcherRulePlugins = []
try {
const ObjectMatcherRulePlugin = require('webpack/lib/rules/ObjectMatcherRulePlugin')
objectMatcherRulePlugins.push(
new ObjectMatcherRulePlugin('assert', 'assertions'),
new ObjectMatcherRulePlugin('descriptionData')
)
} catch (e) {
const DescriptionDataMatcherRulePlugin = require('webpack/lib/rules/DescriptionDataMatcherRulePlugin')
objectMatcherRulePlugins.push(new DescriptionDataMatcherRulePlugin())
}

type RawRule = RuleSetRule

// webpack 5 doesn't export the internal Rule types so we have to shim it here
Expand Down Expand Up @@ -74,7 +85,7 @@ const ruleSetCompiler = new RuleSetCompiler([
new BasicMatcherRulePlugin('realResource'),
new BasicMatcherRulePlugin('issuer'),
new BasicMatcherRulePlugin('compiler'),
new DescriptionDataMatcherRulePlugin(),
...objectMatcherRulePlugins,
new BasicEffectRulePlugin('type'),
new BasicEffectRulePlugin('sideEffects'),
new BasicEffectRulePlugin('parser'),
Expand Down

0 comments on commit b94289c

Please sign in to comment.