@mpxjs/webpack-plugin 2.6.109 → 2.6.110
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 +11 -10
- package/lib/loader.js +11 -4
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -363,10 +363,12 @@ class MpxWebpackPlugin {
|
|
|
363
363
|
compilation.errors.push(e)
|
|
364
364
|
}
|
|
365
365
|
})
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
const queryObj = {}
|
|
367
|
+
if (packageRoot) queryObj.packageRoot = packageRoot
|
|
368
|
+
// todo 后续可以考虑用module.layer来隔离独立分包的模块
|
|
369
|
+
if (isIndependent) queryObj.isIndependent = true
|
|
370
|
+
module.request = addQuery(module.request, queryObj)
|
|
371
|
+
module.resource = addQuery(module.resource, queryObj)
|
|
370
372
|
}
|
|
371
373
|
}
|
|
372
374
|
|
|
@@ -413,6 +415,7 @@ class MpxWebpackPlugin {
|
|
|
413
415
|
// 当前机制下分包处理队列在app.json的json-compiler中进行,由于addEntry回调特性,无法保障app.js中引用的模块都被标记为主包,故重写processModuleDependencies获取app.js及其所有依赖处理完成的时机,在这之后再执行分包处理队列
|
|
414
416
|
appScriptRawRequest: '',
|
|
415
417
|
appScriptPromise: null,
|
|
418
|
+
appScriptPromiseResolve: null,
|
|
416
419
|
// 记录entry依赖关系,用于体积分析
|
|
417
420
|
entryNodesMap: {},
|
|
418
421
|
// 记录entryModule与entryNode的对应关系,用于体积分析
|
|
@@ -590,12 +593,10 @@ class MpxWebpackPlugin {
|
|
|
590
593
|
if (module.rawRequest === mpx.appScriptRawRequest) {
|
|
591
594
|
// 避免模块request重名,只对第一次匹配到的模块进行代理
|
|
592
595
|
mpx.appScriptRawRequest = ''
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
})
|
|
596
|
+
proxyedCallback = (err) => {
|
|
597
|
+
mpx.appScriptPromiseResolve()
|
|
598
|
+
return callback(err)
|
|
599
|
+
}
|
|
599
600
|
}
|
|
600
601
|
return rawProcessModuleDependencies.apply(compilation, [module, proxyedCallback])
|
|
601
602
|
}
|
package/lib/loader.js
CHANGED
|
@@ -273,9 +273,8 @@ module.exports = function (content) {
|
|
|
273
273
|
if (!isProduction) {
|
|
274
274
|
globalInjectCode += `global.currentResource = ${JSON.stringify(filePath)}\n`
|
|
275
275
|
}
|
|
276
|
-
if (ctorType === 'app' && i18n && !mpx.forceDisableInject) {
|
|
277
|
-
globalInjectCode += `global.i18n = ${JSON.stringify({ locale: i18n.locale, version: 0 })}\n`
|
|
278
276
|
|
|
277
|
+
if (i18n && (ctorType === 'app' || (ctorType === 'page' && queryObj.isIndependent)) && !mpx.forceDisableInject) {
|
|
279
278
|
const i18nMethodsVar = 'i18nMethods'
|
|
280
279
|
const i18nWxsPath = normalize.lib('runtime/i18n.wxs')
|
|
281
280
|
const i18nWxsLoaderPath = normalize.lib('wxs/wxs-i18n-loader.js')
|
|
@@ -293,7 +292,10 @@ module.exports = function (content) {
|
|
|
293
292
|
})
|
|
294
293
|
this._module.addVariable(i18nMethodsVar, expression, deps)
|
|
295
294
|
|
|
296
|
-
globalInjectCode += `global.
|
|
295
|
+
globalInjectCode += `if (!global.i18n) {
|
|
296
|
+
global.i18n = ${JSON.stringify({ locale: i18n.locale, version: 0 })}
|
|
297
|
+
global.i18nMethods = ${i18nMethodsVar}
|
|
298
|
+
}\n`
|
|
297
299
|
}
|
|
298
300
|
// 注入构造函数
|
|
299
301
|
let ctor = 'App'
|
|
@@ -329,7 +331,12 @@ module.exports = function (content) {
|
|
|
329
331
|
}
|
|
330
332
|
if (scriptRequestString) {
|
|
331
333
|
output += 'export * from ' + scriptRequestString + '\n\n'
|
|
332
|
-
if (ctorType === 'app')
|
|
334
|
+
if (ctorType === 'app') {
|
|
335
|
+
mpx.appScriptRawRequest = JSON.parse(scriptRequestString)
|
|
336
|
+
mpx.appScriptPromise = new Promise((resolve) => {
|
|
337
|
+
mpx.appScriptPromiseResolve = resolve
|
|
338
|
+
})
|
|
339
|
+
}
|
|
333
340
|
}
|
|
334
341
|
} else {
|
|
335
342
|
switch (ctorType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.110",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"@types/babel-traverse": "^6.25.4",
|
|
82
82
|
"@types/babel-types": "^7.0.4"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "a772b52decbf4a3bdc3b5b608a18327bce453b6c"
|
|
85
85
|
}
|