diff --git a/packages/webpack-plugin/lib/index.js b/packages/webpack-plugin/lib/index.js index 9d8651192b..2c09e14c13 100644 --- a/packages/webpack-plugin/lib/index.js +++ b/packages/webpack-plugin/lib/index.js @@ -897,6 +897,8 @@ class MpxWebpackPlugin { runtimeInfo: {}, // 记录运行时组件依赖的运行时组件当中使用的基础组件 slot,最终依据依赖关系注入到运行时组件的 json 配置当中 dynamicSlotDependencies: {}, + // 模板引擎参数,用来检测模板引擎支持渲染的模板 + dynamicTemplateRuleRunner: this.options.dynamicTemplateRuleRunner, // 依据 package 注入到 mpx-custom-element-*.json 里面的组件路径 getPackageInjectedComponentsMap: (packageName = 'main') => { const res = {} diff --git a/packages/webpack-plugin/lib/template-compiler/compiler.js b/packages/webpack-plugin/lib/template-compiler/compiler.js index 33bae23d20..aa42311d77 100644 --- a/packages/webpack-plugin/lib/template-compiler/compiler.js +++ b/packages/webpack-plugin/lib/template-compiler/compiler.js @@ -2492,6 +2492,10 @@ function processElement (el, root, options, meta) { return } + if (runtimeCompile && options.dynamicTemplateRuleRunner) { + options.dynamicTemplateRuleRunner(el, options, config[mode]) + } + if (rulesRunner && el._atModeStatus !== 'match') { currentEl = el rulesRunner(el) diff --git a/packages/webpack-plugin/lib/template-compiler/index.js b/packages/webpack-plugin/lib/template-compiler/index.js index 4dd16605df..c5c116bc17 100644 --- a/packages/webpack-plugin/lib/template-compiler/index.js +++ b/packages/webpack-plugin/lib/template-compiler/index.js @@ -76,7 +76,8 @@ module.exports = function (raw) { checkUsingComponents: matchCondition(resourcePath, mpx.checkUsingComponentsRules), globalComponents: Object.keys(mpx.usingComponents), forceProxyEvent: matchCondition(resourcePath, mpx.forceProxyEventRules) || runtimeCompile, - hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules) + hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules), + dynamicTemplateRuleRunner: mpx.dynamicTemplateRuleRunner }) if (meta.wxsContentMap) {