@mpxjs/webpack-plugin 2.8.28 → 2.8.30
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 +45 -4
- package/lib/loader.js +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -524,7 +524,7 @@ class MpxWebpackPlugin {
|
|
|
524
524
|
compilation.warnings = compilation.warnings.concat(warnings)
|
|
525
525
|
compilation.errors = compilation.errors.concat(errors)
|
|
526
526
|
const moduleGraph = compilation.moduleGraph
|
|
527
|
-
|
|
527
|
+
|
|
528
528
|
if (!compilation.__mpx__) {
|
|
529
529
|
// init mpx
|
|
530
530
|
mpx = compilation.__mpx__ = {
|
|
@@ -763,9 +763,8 @@ class MpxWebpackPlugin {
|
|
|
763
763
|
async.forEach(presentationalDependencies.filter((dep) => dep.mpxAction), (dep, callback) => {
|
|
764
764
|
dep.mpxAction(module, compilation, callback)
|
|
765
765
|
}, (err) => {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
})
|
|
766
|
+
if (err) compilation.errors.push(err)
|
|
767
|
+
rawProcessModuleDependencies.call(compilation, module, callback)
|
|
769
768
|
})
|
|
770
769
|
}
|
|
771
770
|
|
|
@@ -1074,6 +1073,48 @@ class MpxWebpackPlugin {
|
|
|
1074
1073
|
}
|
|
1075
1074
|
})
|
|
1076
1075
|
|
|
1076
|
+
parser.hooks.evaluate.for('NewExpression').tap('MpxWebpackPlugin', (expression) => {
|
|
1077
|
+
if (/@intlify\/core-base/.test(parser.state.module.resource)) {
|
|
1078
|
+
if (expression.callee.name === 'Function') {
|
|
1079
|
+
const current = parser.state.current
|
|
1080
|
+
current.addPresentationalDependency(new InjectDependency({
|
|
1081
|
+
content: '_mpxCodeTransForm(',
|
|
1082
|
+
index: expression.arguments[0].start
|
|
1083
|
+
}))
|
|
1084
|
+
current.addPresentationalDependency(new InjectDependency({
|
|
1085
|
+
content: ')',
|
|
1086
|
+
index: expression.arguments[0].end
|
|
1087
|
+
}))
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
})
|
|
1091
|
+
parser.hooks.program.tap('MpxWebpackPlugin', ast => {
|
|
1092
|
+
if (/@intlify\/core-base/.test(parser.state.module.resource)) {
|
|
1093
|
+
const current = parser.state.current
|
|
1094
|
+
current.addPresentationalDependency(new InjectDependency({
|
|
1095
|
+
content: 'function _mpxCodeTransForm (code) {\n' +
|
|
1096
|
+
' code = code.replace(/const { (.*?) } = ctx/g, function (match, $1) {\n' +
|
|
1097
|
+
' var arr = $1.split(", ")\n' +
|
|
1098
|
+
' var str = ""\n' +
|
|
1099
|
+
' var pattern = /(.*):(.*)/\n' +
|
|
1100
|
+
' for (var i = 0; i < arr.length; i++) {\n' +
|
|
1101
|
+
' var result = arr[i].match(pattern)\n' +
|
|
1102
|
+
' var left = result[1]\n' +
|
|
1103
|
+
' var right = result[2]\n' +
|
|
1104
|
+
' str += "var" + right + " = ctx." + left\n' +
|
|
1105
|
+
' }\n' +
|
|
1106
|
+
' return str\n' +
|
|
1107
|
+
' })\n' +
|
|
1108
|
+
' code = code.replace(/\\(ctx\\) =>/g, function (match, $1) {\n' +
|
|
1109
|
+
' return "function (ctx)"\n' +
|
|
1110
|
+
' })\n' +
|
|
1111
|
+
' return code\n' +
|
|
1112
|
+
'}',
|
|
1113
|
+
index: ast.end
|
|
1114
|
+
}))
|
|
1115
|
+
}
|
|
1116
|
+
})
|
|
1117
|
+
|
|
1077
1118
|
// 处理跨平台转换
|
|
1078
1119
|
if (mpx.srcMode !== mpx.mode) {
|
|
1079
1120
|
// 处理跨平台全局对象转换
|
package/lib/loader.js
CHANGED
|
@@ -69,7 +69,7 @@ module.exports = function (content) {
|
|
|
69
69
|
|
|
70
70
|
if (ctorType === 'app') {
|
|
71
71
|
const appName = getEntryName(this)
|
|
72
|
-
this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
|
|
72
|
+
if (appName) this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
|
|
73
73
|
}
|
|
74
74
|
const loaderContext = this
|
|
75
75
|
const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.30",
|
|
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": "
|
|
85
|
+
"gitHead": "08cd340b453fc9e0219461d65dbf9232d430a3ae"
|
|
86
86
|
}
|