@mpxjs/webpack-plugin 2.7.9 → 2.7.10

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.
@@ -95,7 +95,6 @@ class DynamicEntryDependency extends NullDependency {
95
95
  const { packageRoot, context } = this
96
96
  this.originEntryNode = mpx.getEntryNode(module)
97
97
  this.publicPath = compilation.outputOptions.publicPath || ''
98
- this.applied = false
99
98
  if (context) this.resolver = compilation.resolverFactory.get('normal', module.resolveOptions)
100
99
  // 分包构建在需要在主包构建完成后在finishMake中处理,返回的资源路径先用key来占位,在合成extractedAssets时再进行最终替换
101
100
  if (packageRoot && mpx.currentPackageRoot !== packageRoot) {
@@ -113,8 +112,10 @@ class DynamicEntryDependency extends NullDependency {
113
112
 
114
113
  // hash会影响最终的codeGenerateResult是否走缓存,由于该dep中resultPath是动态变更的,需要将其更新到hash中,避免错误使用缓存
115
114
  updateHash (hash, context) {
116
- const { resultPath } = this
115
+ const { resultPath, relativePath } = this
117
116
  if (resultPath) hash.update(resultPath)
117
+ // relativePath为MPX_CURRENT_CHUNK时,插入随机数hash使当前module的codeGeneration cache失效,以执行dep.apply动态获取当前module所属的chunk路径
118
+ if (relativePath === MPX_CURRENT_CHUNK) hash.update('' + Math.random())
118
119
  super.updateHash(hash, context)
119
120
  }
120
121
 
@@ -162,7 +163,6 @@ DynamicEntryDependency.Template = class DynamicEntryDependencyTemplate {
162
163
  const replaceRange = `mpx_replace_path_${key}`
163
164
  source.replace(range[0], range[1] - 1, JSON.stringify(replaceRange))
164
165
  }
165
- dep.applied = true
166
166
  }
167
167
  }
168
168
 
package/lib/index.js CHANGED
@@ -407,8 +407,7 @@ class MpxWebpackPlugin {
407
407
  async.each(deps, (dep, callback) => {
408
408
  dep.addEntry(compilation, (err, { resultPath }) => {
409
409
  if (err) return callback(err)
410
- if (dep.applied) mpx.replacePathMap[dep.key] = resultPath
411
- dep.resultPath = resultPath
410
+ dep.resultPath = mpx.replacePathMap[dep.key] = resultPath
412
411
  callback()
413
412
  })
414
413
  }, callback)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.7.9",
3
+ "version": "2.7.10",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -80,5 +80,5 @@
80
80
  "engines": {
81
81
  "node": ">=14.14.0"
82
82
  },
83
- "gitHead": "43b560f84b8e40563c84ef1dc0e4a7d3b4730d93"
83
+ "gitHead": "d5a6a750c6d8dcd94abbdc7812f4ce5ba5050ef7"
84
84
  }