@mpxjs/webpack-plugin 2.8.20 → 2.8.22

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.
@@ -28,10 +28,23 @@ class DynamicEntryDependency extends NullDependency {
28
28
  return toPosix([request, entryType, outputPath, packageRoot, relativePath, context, ...range].join('|'))
29
29
  }
30
30
 
31
+ collectDynamicRequest (mpx) {
32
+ if (!this.packageRoot) return
33
+ const curValue = mpx.dynamicEntryInfo[this.packageRoot] = mpx.dynamicEntryInfo[this.packageRoot] || {
34
+ hasPage: false,
35
+ entries: []
36
+ }
37
+ if (this.entryType === 'page') {
38
+ curValue.hasPage = true
39
+ } else {
40
+ curValue.entries.push(this.request)
41
+ }
42
+ }
43
+
31
44
  addEntry (compilation, callback) {
32
45
  const mpx = compilation.__mpx__
33
46
  let { request, entryType, outputPath, relativePath, context, originEntryNode, publicPath, resolver } = this
34
-
47
+ this.collectDynamicRequest(mpx)
35
48
  async.waterfall([
36
49
  (callback) => {
37
50
  if (context && resolver) {
package/lib/index.js CHANGED
@@ -453,7 +453,20 @@ class MpxWebpackPlugin {
453
453
  name: 'MpxWebpackPlugin',
454
454
  stage: -1000
455
455
  }, (compilation, callback) => {
456
- processSubpackagesEntriesMap(compilation, callback)
456
+ processSubpackagesEntriesMap(compilation, () => {
457
+ const checkRegisterPack = () => {
458
+ for (const packRoot in mpx.dynamicEntryInfo) {
459
+ const entryMap = mpx.dynamicEntryInfo[packRoot]
460
+ if (!entryMap.hasPage) {
461
+ // 引用未注册分包的所有资源
462
+ const strRequest = entryMap.entries.join(',')
463
+ compilation.errors.push(new Error(`资源${strRequest}目标是打入${packRoot}分包, 但是app.json中并未声明${packRoot}分包`))
464
+ }
465
+ }
466
+ }
467
+ checkRegisterPack()
468
+ callback()
469
+ })
457
470
  })
458
471
 
459
472
  compiler.hooks.compilation.tap('MpxWebpackPlugin ', (compilation, { normalModuleFactory }) => {
@@ -537,6 +550,8 @@ class MpxWebpackPlugin {
537
550
  subpackagesEntriesMap: {},
538
551
  replacePathMap: {},
539
552
  exportModules: new Set(),
553
+ // 动态记录注册的分包与注册页面映射
554
+ dynamicEntryInfo: {},
540
555
  // 记录entryModule与entryNode的对应关系,用于体积分析
541
556
  entryNodeModulesMap: new Map(),
542
557
  // 记录与asset相关联的modules,用于体积分析
@@ -1497,7 +1512,7 @@ try {
1497
1512
  })
1498
1513
  }
1499
1514
 
1500
- compiler.hooks.done.tapPromise('MpxWebpackPlugin', async () => {
1515
+ compiler.hooks.done.tapPromise('MpxWebpackPlugin', async (stats) => {
1501
1516
  const cache = compiler.getCache('MpxWebpackPlugin')
1502
1517
  const cacheIsValid = await cache.getPromise('cacheIsValid', null)
1503
1518
  if (!cacheIsValid) {
@@ -328,7 +328,7 @@ function compileScriptSetup (
328
328
  } }`
329
329
  } else {
330
330
  return `${key}: { type: ${propRuntimeTypes.type}${
331
- defaultString ? `, ${defaultString}` : null
331
+ defaultString ? `, ${defaultString}` : ''
332
332
  } }`
333
333
  }
334
334
  }).join(',\n ')}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.8.20",
3
+ "version": "2.8.22",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -82,5 +82,5 @@
82
82
  "engines": {
83
83
  "node": ">=14.14.0"
84
84
  },
85
- "gitHead": "c330d3938cc0c37843761df8b1f2deb9b6c618fc"
85
+ "gitHead": "6e809a7699a94f12213b350e8f8b0f73d7d2a223"
86
86
  }