@mpxjs/webpack-plugin 2.9.24 → 2.9.27
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/config.js +5 -1
- package/lib/dependencies/DynamicEntryDependency.js +8 -5
- package/lib/index.js +4 -5
- package/lib/json-compiler/helper.js +4 -4
- package/lib/json-compiler/index.js +14 -4
- package/lib/platform/json/wx/index.js +3 -1
- package/lib/runtime/components/web/event.js +1 -3
- package/lib/runtime/i18n.wxs +5 -1
- package/lib/template-compiler/compiler.js +0 -7
- package/lib/utils/resolve-tab-bar-path.js +3 -0
- package/package.json +2 -2
package/lib/config.js
CHANGED
|
@@ -7,6 +7,7 @@ module.exports = {
|
|
|
7
7
|
styles: '.wxss'
|
|
8
8
|
},
|
|
9
9
|
tabBar: {
|
|
10
|
+
customKey: 'custom',
|
|
10
11
|
itemKey: 'list',
|
|
11
12
|
iconKey: 'iconPath',
|
|
12
13
|
activeIconKey: 'selectedIconPath'
|
|
@@ -74,6 +75,7 @@ module.exports = {
|
|
|
74
75
|
styles: '.acss'
|
|
75
76
|
},
|
|
76
77
|
tabBar: {
|
|
78
|
+
customKey: 'customize',
|
|
77
79
|
itemKey: 'items',
|
|
78
80
|
iconKey: 'icon',
|
|
79
81
|
activeIconKey: 'activeIcon'
|
|
@@ -83,7 +85,7 @@ module.exports = {
|
|
|
83
85
|
},
|
|
84
86
|
event: {
|
|
85
87
|
parseEvent (attr) {
|
|
86
|
-
const match = /^(on|catch)([A-Z].*?)(?:\.(.*))?$/.exec(attr)
|
|
88
|
+
const match = /^(on|catch|capture-on|capture-catch)([A-Z].*?)(?:\.(.*))?$/.exec(attr)
|
|
87
89
|
if (match) {
|
|
88
90
|
return {
|
|
89
91
|
prefix: match[1],
|
|
@@ -216,6 +218,7 @@ module.exports = {
|
|
|
216
218
|
styles: '.qss'
|
|
217
219
|
},
|
|
218
220
|
tabBar: {
|
|
221
|
+
customKey: 'custom',
|
|
219
222
|
itemKey: 'list',
|
|
220
223
|
iconKey: 'iconPath',
|
|
221
224
|
activeIconKey: 'selectedIconPath'
|
|
@@ -364,6 +367,7 @@ module.exports = {
|
|
|
364
367
|
styles: '.css'
|
|
365
368
|
},
|
|
366
369
|
tabBar: {
|
|
370
|
+
customKey: 'custom',
|
|
367
371
|
itemKey: 'list',
|
|
368
372
|
iconKey: 'iconPath',
|
|
369
373
|
activeIconKey: 'selectedIconPath'
|
|
@@ -7,7 +7,7 @@ const async = require('async')
|
|
|
7
7
|
const parseRequest = require('../utils/parse-request')
|
|
8
8
|
|
|
9
9
|
class DynamicEntryDependency extends NullDependency {
|
|
10
|
-
constructor (request, entryType, outputPath = '', packageRoot = '', relativePath = '', context = '',
|
|
10
|
+
constructor (range, request, entryType, outputPath = '', packageRoot = '', relativePath = '', context = '', extraOptions = {}) {
|
|
11
11
|
super()
|
|
12
12
|
this.request = request
|
|
13
13
|
this.entryType = entryType
|
|
@@ -16,6 +16,10 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
16
16
|
this.relativePath = relativePath
|
|
17
17
|
this.context = context
|
|
18
18
|
this.range = range
|
|
19
|
+
|
|
20
|
+
if (typeof extraOptions === 'string') {
|
|
21
|
+
extraOptions = JSON.parse(extraOptions)
|
|
22
|
+
}
|
|
19
23
|
this.extraOptions = extraOptions
|
|
20
24
|
}
|
|
21
25
|
|
|
@@ -182,13 +186,12 @@ DynamicEntryDependency.Template = class DynamicEntryDependencyTemplate {
|
|
|
182
186
|
module,
|
|
183
187
|
chunkGraph
|
|
184
188
|
}) {
|
|
185
|
-
const { resultPath, range, key,
|
|
189
|
+
const { resultPath, range, key, publicPath, extraOptions } = dep
|
|
186
190
|
|
|
187
191
|
let replaceContent = ''
|
|
188
192
|
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
replaceContent = JSON.stringify(true)
|
|
193
|
+
if (extraOptions.replaceContent) {
|
|
194
|
+
replaceContent = extraOptions.replaceContent
|
|
192
195
|
} else if (resultPath) {
|
|
193
196
|
if (extraOptions.isRequireAsync) {
|
|
194
197
|
let relativePath = toPosix(path.relative(publicPath + path.dirname(chunkGraph.getModuleChunks(module)[0].name), resultPath))
|
package/lib/index.js
CHANGED
|
@@ -172,7 +172,6 @@ class MpxWebpackPlugin {
|
|
|
172
172
|
options.asyncSubpackageRules = options.asyncSubpackageRules || []
|
|
173
173
|
options.optimizeRenderRules = options.optimizeRenderRules ? (Array.isArray(options.optimizeRenderRules) ? options.optimizeRenderRules : [options.optimizeRenderRules]) : []
|
|
174
174
|
options.retryRequireAsync = options.retryRequireAsync || false
|
|
175
|
-
options.enableAliRequireAsync = options.enableAliRequireAsync || false
|
|
176
175
|
options.optimizeSize = options.optimizeSize || false
|
|
177
176
|
this.options = options
|
|
178
177
|
// Hack for buildDependencies
|
|
@@ -649,7 +648,7 @@ class MpxWebpackPlugin {
|
|
|
649
648
|
useRelativePath: this.options.useRelativePath,
|
|
650
649
|
removedChunks: [],
|
|
651
650
|
forceProxyEventRules: this.options.forceProxyEventRules,
|
|
652
|
-
supportRequireAsync: this.options.mode === 'wx' || this.options.mode === 'web' ||
|
|
651
|
+
supportRequireAsync: this.options.mode === 'wx' || this.options.mode === 'web' || this.options.mode === 'ali',
|
|
653
652
|
partialCompile: this.options.partialCompile,
|
|
654
653
|
collectDynamicEntryInfo: ({ resource, packageName, filename, entryType }) => {
|
|
655
654
|
const curInfo = mpx.dynamicEntryInfo[packageName] = mpx.dynamicEntryInfo[packageName] || {
|
|
@@ -1101,7 +1100,7 @@ class MpxWebpackPlugin {
|
|
|
1101
1100
|
|
|
1102
1101
|
parser.hooks.call.for('__mpx_dynamic_entry__').tap('MpxWebpackPlugin', (expr) => {
|
|
1103
1102
|
const args = expr.arguments.map((i) => i.value)
|
|
1104
|
-
args.
|
|
1103
|
+
args.unshift(expr.range)
|
|
1105
1104
|
|
|
1106
1105
|
const dep = new DynamicEntryDependency(...args)
|
|
1107
1106
|
parser.state.current.addPresentationalDependency(dep)
|
|
@@ -1126,7 +1125,7 @@ class MpxWebpackPlugin {
|
|
|
1126
1125
|
if (tarRoot) {
|
|
1127
1126
|
// 删除root query
|
|
1128
1127
|
if (queryObj.root) request = addQuery(request, {}, false, ['root'])
|
|
1129
|
-
// wx、ali
|
|
1128
|
+
// wx、ali和web平台支持require.async,其余平台使用CommonJsAsyncDependency进行模拟抹平
|
|
1130
1129
|
if (mpx.supportRequireAsync) {
|
|
1131
1130
|
if (mpx.mode === 'web') {
|
|
1132
1131
|
const depBlock = new AsyncDependenciesBlock(
|
|
@@ -1141,7 +1140,7 @@ class MpxWebpackPlugin {
|
|
|
1141
1140
|
depBlock.addDependency(dep)
|
|
1142
1141
|
parser.state.current.addBlock(depBlock)
|
|
1143
1142
|
} else {
|
|
1144
|
-
const dep = new DynamicEntryDependency(request, 'export', '', tarRoot, '', context,
|
|
1143
|
+
const dep = new DynamicEntryDependency(range, request, 'export', '', tarRoot, '', context, {
|
|
1145
1144
|
isRequireAsync: true,
|
|
1146
1145
|
retryRequireAsync: !!this.options.retryRequireAsync
|
|
1147
1146
|
})
|
|
@@ -28,10 +28,10 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
28
28
|
|
|
29
29
|
let dynamicEntryCount = 0
|
|
30
30
|
|
|
31
|
-
const getDynamicEntry = (request, type, outputPath = '', packageRoot = '', relativePath = '', context = '') => {
|
|
31
|
+
const getDynamicEntry = (request, type, outputPath = '', packageRoot = '', relativePath = '', context = '', extraOptions = {}) => {
|
|
32
32
|
if (typeof customGetDynamicEntry === 'function') return customGetDynamicEntry(request, type, outputPath, packageRoot, relativePath, context)
|
|
33
33
|
const key = `mpx_dynamic_entry_${dynamicEntryCount++}`
|
|
34
|
-
const value = `__mpx_dynamic_entry__( ${JSON.stringify(request)},${JSON.stringify(type)},${JSON.stringify(outputPath)},${JSON.stringify(packageRoot)},${JSON.stringify(relativePath)},${JSON.stringify(context)})`
|
|
34
|
+
const value = `__mpx_dynamic_entry__( ${JSON.stringify(request)},${JSON.stringify(type)},${JSON.stringify(outputPath)},${JSON.stringify(packageRoot)},${JSON.stringify(relativePath)},${JSON.stringify(context)},'${JSON.stringify(extraOptions)}')`
|
|
35
35
|
dynamicEntryMap.set(key, value)
|
|
36
36
|
return key
|
|
37
37
|
}
|
|
@@ -43,7 +43,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
43
43
|
})
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const processComponent = (component, context, { tarRoot = '', outputPath = '', relativePath = '' }, callback) => {
|
|
46
|
+
const processComponent = (component, context, { tarRoot = '', outputPath = '', relativePath = '', extraOptions = {} }, callback) => {
|
|
47
47
|
if (!isUrlRequest(component)) return callback(null, component)
|
|
48
48
|
if (resolveMode === 'native') {
|
|
49
49
|
component = urlToRequest(component)
|
|
@@ -96,7 +96,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
96
96
|
resource = `!!${nativeLoaderPath}!${resource}`
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
const entry = getDynamicEntry(resource, 'component', outputPath, tarRoot, relativePath)
|
|
99
|
+
const entry = getDynamicEntry(resource, 'component', outputPath, tarRoot, relativePath, '', extraOptions)
|
|
100
100
|
callback(null, entry, {
|
|
101
101
|
tarRoot,
|
|
102
102
|
placeholder
|
|
@@ -14,6 +14,7 @@ const RecordGlobalComponentsDependency = require('../dependencies/RecordGlobalCo
|
|
|
14
14
|
const RecordIndependentDependency = require('../dependencies/RecordIndependentDependency')
|
|
15
15
|
const { MPX_DISABLE_EXTRACTOR_CACHE, RESOLVE_IGNORED_ERR, JSON_JS_EXT } = require('../utils/const')
|
|
16
16
|
const resolve = require('../utils/resolve')
|
|
17
|
+
const resolveTabBarPath = require('../utils/resolve-tab-bar-path')
|
|
17
18
|
const normalize = require('../utils/normalize')
|
|
18
19
|
const mpxViewPath = normalize.lib('runtime/components/ali/mpx-view.mpx')
|
|
19
20
|
const mpxTextPath = normalize.lib('runtime/components/ali/mpx-text.mpx')
|
|
@@ -532,14 +533,23 @@ module.exports = function (content) {
|
|
|
532
533
|
}
|
|
533
534
|
|
|
534
535
|
const processCustomTabBar = (tabBar, context, callback) => {
|
|
535
|
-
|
|
536
|
-
|
|
536
|
+
const outputCustomKey = config[mode].tabBar.customKey
|
|
537
|
+
if (tabBar && tabBar[outputCustomKey]) {
|
|
538
|
+
const srcCustomKey = config[srcMode].tabBar.customKey
|
|
539
|
+
const srcPath = resolveTabBarPath(srcCustomKey)
|
|
540
|
+
const outputPath = resolveTabBarPath(outputCustomKey)
|
|
541
|
+
const dynamicEntryExtraOptions = {
|
|
542
|
+
// replace with true for custom-tab-bar
|
|
543
|
+
replaceContent: 'true'
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
processComponent(`./${srcPath}`, context, { outputPath, extraOptions: dynamicEntryExtraOptions }, (err, entry) => {
|
|
537
547
|
if (err === RESOLVE_IGNORED_ERR) {
|
|
538
|
-
delete tabBar
|
|
548
|
+
delete tabBar[srcCustomKey]
|
|
539
549
|
return callback()
|
|
540
550
|
}
|
|
541
551
|
if (err) return callback(err)
|
|
542
|
-
tabBar
|
|
552
|
+
tabBar[outputCustomKey] = entry // hack for javascript parser call hook.
|
|
543
553
|
callback()
|
|
544
554
|
})
|
|
545
555
|
} else {
|
|
@@ -325,7 +325,9 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
325
325
|
},
|
|
326
326
|
{
|
|
327
327
|
test: 'custom',
|
|
328
|
-
ali:
|
|
328
|
+
ali: function (input) {
|
|
329
|
+
return changeKey(input, this.test, 'customize')
|
|
330
|
+
},
|
|
329
331
|
swan: deletePath(),
|
|
330
332
|
tt: deletePath(),
|
|
331
333
|
jd: deletePath()
|
|
@@ -59,9 +59,7 @@ function MpxEvent (layer) {
|
|
|
59
59
|
this.sendEvent(this.targetElement, 'tap', event)
|
|
60
60
|
}
|
|
61
61
|
this.sendEvent = (targetElement, type, event) => {
|
|
62
|
-
|
|
63
|
-
const touchEvent = new TouchEvent(type, {
|
|
64
|
-
view: window,
|
|
62
|
+
const touchEvent = new CustomEvent(type, {
|
|
65
63
|
bubbles: true,
|
|
66
64
|
cancelable: true
|
|
67
65
|
})
|
package/lib/runtime/i18n.wxs
CHANGED
|
@@ -271,7 +271,11 @@ function getMessage (messages, locale, fallbackLocale, key) {
|
|
|
271
271
|
|
|
272
272
|
function resolve (messages, locale, key) {
|
|
273
273
|
if (messages && messages[locale] && key) {
|
|
274
|
-
|
|
274
|
+
var format = getPathValue(messages[locale], key)
|
|
275
|
+
if (format == null) {
|
|
276
|
+
format = messages[locale][key]
|
|
277
|
+
}
|
|
278
|
+
return format
|
|
275
279
|
}
|
|
276
280
|
}
|
|
277
281
|
|
|
@@ -1355,13 +1355,6 @@ function processRef (el, options, meta) {
|
|
|
1355
1355
|
all
|
|
1356
1356
|
})
|
|
1357
1357
|
}
|
|
1358
|
-
|
|
1359
|
-
if (type === 'component' && mode === 'ali') {
|
|
1360
|
-
addAttrs(el, [{
|
|
1361
|
-
name: 'onUpdateRef',
|
|
1362
|
-
value: '__handleUpdateRef'
|
|
1363
|
-
}])
|
|
1364
|
-
}
|
|
1365
1358
|
}
|
|
1366
1359
|
|
|
1367
1360
|
function addWxsModule (meta, module, src) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.27",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": ">=14.14.0"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "3939aaaa7d9be0c86e51da16080a6cd8d7863a1a"
|
|
87
87
|
}
|