@mpxjs/webpack-plugin 2.9.54 → 2.9.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -535,6 +535,16 @@ class MpxWebpackPlugin {
535
535
  }
536
536
  }
537
537
 
538
+ const checkDynamicEntryInfo = (compilation) => {
539
+ for (const packageName in mpx.dynamicEntryInfo) {
540
+ const entryMap = mpx.dynamicEntryInfo[packageName]
541
+ if (packageName !== 'main' && !entryMap.hasPage) {
542
+ // 引用未注册分包的所有资源
543
+ const resources = entryMap.entries.map(info => info.resource).join(',')
544
+ compilation.errors.push(new Error(`资源${resources}通过分包异步声明为${packageName}分包, 但${packageName}分包未注册或不存在相关页面!`))
545
+ }
546
+ }
547
+ }
538
548
  // 构建分包队列,在finishMake钩子当中最先执行,stage传递-1000
539
549
  compiler.hooks.finishMake.tapAsync({
540
550
  name: 'MpxWebpackPlugin',
@@ -549,17 +559,10 @@ class MpxWebpackPlugin {
549
559
  }
550
560
  ], (err) => {
551
561
  if (err) return callback(err)
552
- const checkDynamicEntryInfo = () => {
553
- for (const packageName in mpx.dynamicEntryInfo) {
554
- const entryMap = mpx.dynamicEntryInfo[packageName]
555
- if (packageName !== 'main' && !entryMap.hasPage) {
556
- // 引用未注册分包的所有资源
557
- const resources = entryMap.entries.map(info => info.resource).join(',')
558
- compilation.errors.push(new Error(`资源${resources}通过分包异步声明为${packageName}分包, 但${packageName}分包未注册或不存在相关页面!`))
559
- }
560
- }
562
+ if (mpx.supportRequireAsync && mpx.mode !== 'tt') {
563
+ // 字节小程序异步分包中不能包含page,忽略该检查
564
+ checkDynamicEntryInfo(compilation)
561
565
  }
562
- checkDynamicEntryInfo()
563
566
  callback()
564
567
  })
565
568
  })
@@ -894,6 +897,8 @@ class MpxWebpackPlugin {
894
897
  runtimeInfo: {},
895
898
  // 记录运行时组件依赖的运行时组件当中使用的基础组件 slot,最终依据依赖关系注入到运行时组件的 json 配置当中
896
899
  dynamicSlotDependencies: {},
900
+ // 模板引擎参数,用来检测模板引擎支持渲染的模板
901
+ dynamicTemplateRuleRunner: this.options.dynamicTemplateRuleRunner,
897
902
  // 依据 package 注入到 mpx-custom-element-*.json 里面的组件路径
898
903
  getPackageInjectedComponentsMap: (packageName = 'main') => {
899
904
  const res = {}
@@ -706,7 +706,8 @@ module.exports = function (content) {
706
706
  for (const root in subPackagesCfg) {
707
707
  const subPackageCfg = subPackagesCfg[root]
708
708
  // 分包不存在 pages,输出 subPackages 字段会报错
709
- if (subPackageCfg.pages.length) {
709
+ // tt模式下分包异步允许一个分包不存在 pages
710
+ if (subPackageCfg.pages.length || mode === 'tt') {
710
711
  if (!json.subPackages) {
711
712
  json.subPackages = []
712
713
  }
@@ -153,7 +153,6 @@ module.exports = function getSpec ({ warn, error }) {
153
153
  test: 'componentPlaceholder',
154
154
  ali: aliComponentPlaceholderFallback,
155
155
  swan: deletePath(),
156
- tt: deletePath(),
157
156
  jd: deletePath()
158
157
  },
159
158
  {
@@ -2492,6 +2492,10 @@ function processElement (el, root, options, meta) {
2492
2492
  return
2493
2493
  }
2494
2494
 
2495
+ if (runtimeCompile && options.dynamicTemplateRuleRunner) {
2496
+ options.dynamicTemplateRuleRunner(el, options, config[mode])
2497
+ }
2498
+
2495
2499
  if (rulesRunner && el._atModeStatus !== 'match') {
2496
2500
  currentEl = el
2497
2501
  rulesRunner(el)
@@ -76,7 +76,8 @@ module.exports = function (raw) {
76
76
  checkUsingComponents: matchCondition(resourcePath, mpx.checkUsingComponentsRules),
77
77
  globalComponents: Object.keys(mpx.usingComponents),
78
78
  forceProxyEvent: matchCondition(resourcePath, mpx.forceProxyEventRules) || runtimeCompile,
79
- hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules)
79
+ hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules),
80
+ dynamicTemplateRuleRunner: mpx.dynamicTemplateRuleRunner
80
81
  })
81
82
 
82
83
  if (meta.wxsContentMap) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.9.54",
3
+ "version": "2.9.56",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -86,5 +86,5 @@
86
86
  "engines": {
87
87
  "node": ">=14.14.0"
88
88
  },
89
- "gitHead": "973791aa35b1846bb96efe421f7ce266b2531455"
89
+ "gitHead": "4175767d6ccf695ced81c9c7ced5eccd80445929"
90
90
  }