From c4c5f173433801c8e3a6b28738129cf599498c06 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Mon, 2 Aug 2021 23:57:10 +0800 Subject: [PATCH] fix: fix webpack 5.48 compatibility Fixes #1859 --- lib/plugin-webpack5.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/plugin-webpack5.js b/lib/plugin-webpack5.js index 91126ffec..38df2431c 100644 --- a/lib/plugin-webpack5.js +++ b/lib/plugin-webpack5.js @@ -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'), @@ -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'),