@mpxjs/webpack-plugin 2.9.26 → 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 +2 -2
- 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/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
|
@@ -1100,7 +1100,7 @@ class MpxWebpackPlugin {
|
|
|
1100
1100
|
|
|
1101
1101
|
parser.hooks.call.for('__mpx_dynamic_entry__').tap('MpxWebpackPlugin', (expr) => {
|
|
1102
1102
|
const args = expr.arguments.map((i) => i.value)
|
|
1103
|
-
args.
|
|
1103
|
+
args.unshift(expr.range)
|
|
1104
1104
|
|
|
1105
1105
|
const dep = new DynamicEntryDependency(...args)
|
|
1106
1106
|
parser.state.current.addPresentationalDependency(dep)
|
|
@@ -1140,7 +1140,7 @@ class MpxWebpackPlugin {
|
|
|
1140
1140
|
depBlock.addDependency(dep)
|
|
1141
1141
|
parser.state.current.addBlock(depBlock)
|
|
1142
1142
|
} else {
|
|
1143
|
-
const dep = new DynamicEntryDependency(request, 'export', '', tarRoot, '', context,
|
|
1143
|
+
const dep = new DynamicEntryDependency(range, request, 'export', '', tarRoot, '', context, {
|
|
1144
1144
|
isRequireAsync: true,
|
|
1145
1145
|
retryRequireAsync: !!this.options.retryRequireAsync
|
|
1146
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()
|
|
@@ -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
|
}
|