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
haoqunjiang committed Aug 2, 2021
1 parent 689075d commit c4c5f17
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/plugin-webpack5.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@ const id = 'vue-loader-plugin'
const NS = 'vue-loader'
const BasicEffectRulePlugin = require('webpack/lib/rules/BasicEffectRulePlugin')
const BasicMatcherRulePlugin = require('webpack/lib/rules/BasicMatcherRulePlugin')
const DescriptionDataMatcherRulePlugin = require('webpack/lib/rules/DescriptionDataMatcherRulePlugin')
const RuleSetCompiler = require('webpack/lib/rules/RuleSetCompiler')
const UseEffectRulePlugin = require('webpack/lib/rules/UseEffectRulePlugin')

const 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())
}

const ruleSetCompiler = new RuleSetCompiler([
new BasicMatcherRulePlugin('test', 'resource'),
new BasicMatcherRulePlugin('mimetype'),
Expand All @@ -20,7 +31,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 c4c5f17

Please sign in to comment.