@mpxjs/webpack-plugin 2.7.45 → 2.7.46
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/helpers.js +3 -1
- package/lib/index.js +5 -2
- package/lib/selector.js +5 -5
- package/lib/wxs/WxsPlugin.js +8 -0
- package/lib/wxs/WxsTemplatePlugin.js +1 -1
- package/package.json +2 -2
package/lib/helpers.js
CHANGED
|
@@ -16,6 +16,8 @@ module.exports = function createHelpers (loaderContext) {
|
|
|
16
16
|
const rawRequest = loaderUtils.getRemainingRequest(loaderContext)
|
|
17
17
|
const { resourcePath, queryObj } = parseRequest(loaderContext.resource)
|
|
18
18
|
|
|
19
|
+
const { mode, env } = loaderContext.getMpx() || {}
|
|
20
|
+
|
|
19
21
|
function getRequire (type, part, extraOptions, index) {
|
|
20
22
|
return 'require(' + getRequestString(type, part, extraOptions, index) + ')'
|
|
21
23
|
}
|
|
@@ -66,7 +68,7 @@ module.exports = function createHelpers (loaderContext) {
|
|
|
66
68
|
return loaderUtils.stringifyRequest(loaderContext, addQuery(src, options, true))
|
|
67
69
|
} else {
|
|
68
70
|
const fakeRequest = getFakeRequest(type, part)
|
|
69
|
-
const request = `${selectorPath}!${addQuery(rawRequest, options, true)}`
|
|
71
|
+
const request = `${selectorPath}?mode=${mode}&env=${env}!${addQuery(rawRequest, options, true)}`
|
|
70
72
|
return loaderUtils.stringifyRequest(loaderContext, `${fakeRequest}!=!${request}`)
|
|
71
73
|
}
|
|
72
74
|
}
|
package/lib/index.js
CHANGED
|
@@ -941,7 +941,7 @@ class MpxWebpackPlugin {
|
|
|
941
941
|
}
|
|
942
942
|
})
|
|
943
943
|
|
|
944
|
-
|
|
944
|
+
const normalModuleFactoryParserCallback = (parser) => {
|
|
945
945
|
parser.hooks.call.for('__mpx_resolve_path__').tap('MpxWebpackPlugin', (expr) => {
|
|
946
946
|
if (expr.arguments[0]) {
|
|
947
947
|
const resource = expr.arguments[0].value
|
|
@@ -1152,7 +1152,10 @@ class MpxWebpackPlugin {
|
|
|
1152
1152
|
parser.hooks.callMemberChain.for('mpx').tap('MpxWebpackPlugin', injectSrcModeForTransApi)
|
|
1153
1153
|
parser.hooks.callMemberChain.for('wx').tap('MpxWebpackPlugin', injectSrcModeForTransApi)
|
|
1154
1154
|
}
|
|
1155
|
-
}
|
|
1155
|
+
}
|
|
1156
|
+
normalModuleFactory.hooks.parser.for('javascript/auto').tap('MpxWebpackPlugin', normalModuleFactoryParserCallback)
|
|
1157
|
+
normalModuleFactory.hooks.parser.for('javascript/dynamic').tap('MpxWebpackPlugin', normalModuleFactoryParserCallback)
|
|
1158
|
+
normalModuleFactory.hooks.parser.for('javascript/esm').tap('MpxWebpackPlugin', normalModuleFactoryParserCallback)
|
|
1156
1159
|
|
|
1157
1160
|
// 为了正确生成sourceMap,将该步骤由原来的compile.hooks.emit迁移到compilation.hooks.processAssets
|
|
1158
1161
|
compilation.hooks.processAssets.tap({
|
package/lib/selector.js
CHANGED
|
@@ -3,17 +3,17 @@ const parseRequest = require('./utils/parse-request')
|
|
|
3
3
|
|
|
4
4
|
module.exports = function (content) {
|
|
5
5
|
this.cacheable()
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
// 移除mpx访问依赖,支持 thread-loader
|
|
8
|
+
const { mode, env } = this.getOptions() || {}
|
|
9
|
+
if (!mode && !env) {
|
|
9
10
|
return content
|
|
10
11
|
}
|
|
12
|
+
|
|
11
13
|
const { queryObj } = parseRequest(this.resource)
|
|
12
14
|
const ctorType = queryObj.ctorType
|
|
13
15
|
const type = queryObj.type
|
|
14
16
|
const index = queryObj.index || 0
|
|
15
|
-
const mode = mpx.mode
|
|
16
|
-
const env = mpx.env
|
|
17
17
|
const filePath = this.resourcePath
|
|
18
18
|
const parts = parseComponent(content, {
|
|
19
19
|
filePath,
|
package/lib/wxs/WxsPlugin.js
CHANGED
|
@@ -23,6 +23,14 @@ class WxsPlugin {
|
|
|
23
23
|
normalModuleFactory.hooks.parser
|
|
24
24
|
.for('javascript/auto')
|
|
25
25
|
.tap('WxsPlugin', handler)
|
|
26
|
+
|
|
27
|
+
normalModuleFactory.hooks.parser
|
|
28
|
+
.for('javascript/dynamic')
|
|
29
|
+
.tap('WxsPlugin', handler)
|
|
30
|
+
|
|
31
|
+
normalModuleFactory.hooks.parser
|
|
32
|
+
.for('javascript/esm')
|
|
33
|
+
.tap('WxsPlugin', handler)
|
|
26
34
|
})
|
|
27
35
|
}
|
|
28
36
|
}
|
|
@@ -35,7 +35,7 @@ class CompatGetDefaultExportRuntimeModule extends HelperRuntimeModule {
|
|
|
35
35
|
`${fn} = ${runtimeTemplate.basicFunction('module', [
|
|
36
36
|
'var getter = module && module.__esModule ?',
|
|
37
37
|
Template.indent([
|
|
38
|
-
`${runtimeTemplate.returningFunction('module
|
|
38
|
+
`${runtimeTemplate.returningFunction('module["default"]')} :`,
|
|
39
39
|
`${runtimeTemplate.returningFunction('module')};`
|
|
40
40
|
]),
|
|
41
41
|
'getter.a = getter();',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.46",
|
|
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": "
|
|
83
|
+
"gitHead": "5c8b46722d862bba145badd164c4675a43a577c3"
|
|
84
84
|
}
|