@mpxjs/webpack-plugin 2.9.31 → 2.9.33
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/loader.js
CHANGED
|
@@ -83,7 +83,7 @@ module.exports = function (content) {
|
|
|
83
83
|
const loaderContext = this
|
|
84
84
|
const isProduction = this.minimize || process.env.NODE_ENV === 'production'
|
|
85
85
|
const filePath = this.resourcePath
|
|
86
|
-
const moduleId = ctorType === 'app' ? MPX_APP_MODULE_ID : mpx.pathHash(filePath)
|
|
86
|
+
const moduleId = ctorType === 'app' ? MPX_APP_MODULE_ID : '_' + mpx.pathHash(filePath)
|
|
87
87
|
|
|
88
88
|
const parts = parseComponent(content, {
|
|
89
89
|
filePath,
|
package/lib/native-loader.js
CHANGED
|
@@ -188,7 +188,7 @@ module.exports = function (content) {
|
|
|
188
188
|
if (appName) this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
const moduleId = ctorType === 'app' ? MPX_APP_MODULE_ID : mpx.pathHash(filePath)
|
|
191
|
+
const moduleId = ctorType === 'app' ? MPX_APP_MODULE_ID : '_' + mpx.pathHash(filePath)
|
|
192
192
|
|
|
193
193
|
if (ctorType !== 'app') {
|
|
194
194
|
rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
|
|
@@ -15,7 +15,7 @@ module.exports = function (css, map) {
|
|
|
15
15
|
const cb = this.async()
|
|
16
16
|
const { resourcePath, queryObj } = parseRequest(this.resource)
|
|
17
17
|
const mpx = this.getMpx()
|
|
18
|
-
const id = queryObj.moduleId || queryObj.mid || mpx.pathHash(resourcePath)
|
|
18
|
+
const id = queryObj.moduleId || queryObj.mid || '_' + mpx.pathHash(resourcePath)
|
|
19
19
|
const appInfo = mpx.appInfo
|
|
20
20
|
const defs = mpx.defs
|
|
21
21
|
const mode = mpx.mode
|
|
@@ -104,7 +104,7 @@ let env
|
|
|
104
104
|
let platformGetTagNamespace
|
|
105
105
|
let filePath
|
|
106
106
|
let refId
|
|
107
|
-
let
|
|
107
|
+
let hasOptionalChain = false
|
|
108
108
|
|
|
109
109
|
function updateForScopesMap () {
|
|
110
110
|
forScopes.forEach((scope) => {
|
|
@@ -165,8 +165,8 @@ const i18nWxsRequest = '~' + i18nWxsLoaderPath + '!' + i18nWxsPath
|
|
|
165
165
|
const i18nModuleName = '__i18n__'
|
|
166
166
|
const stringifyWxsPath = '~' + normalize.lib('runtime/stringify.wxs')
|
|
167
167
|
const stringifyModuleName = '__stringify__'
|
|
168
|
-
const
|
|
169
|
-
const
|
|
168
|
+
const optionalChainWxsPath = '~' + normalize.lib('runtime/oc.wxs')
|
|
169
|
+
const optionalChainWxsName = '__oc__'
|
|
170
170
|
|
|
171
171
|
const tagRES = /(\{\{(?:.|\n|\r)+?\}\})(?!})/
|
|
172
172
|
const tagRE = /\{\{((?:.|\n|\r)+?)\}\}(?!})/
|
|
@@ -640,7 +640,7 @@ function parse (template, options) {
|
|
|
640
640
|
forScopes = []
|
|
641
641
|
forScopesMap = {}
|
|
642
642
|
hasI18n = false
|
|
643
|
-
|
|
643
|
+
hasOptionalChain = false
|
|
644
644
|
|
|
645
645
|
platformGetTagNamespace = options.getTagNamespace || no
|
|
646
646
|
|
|
@@ -765,8 +765,8 @@ function parse (template, options) {
|
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
767
|
|
|
768
|
-
if (
|
|
769
|
-
injectWxs(meta,
|
|
768
|
+
if (hasOptionalChain) {
|
|
769
|
+
injectWxs(meta, optionalChainWxsName, optionalChainWxsPath)
|
|
770
770
|
}
|
|
771
771
|
|
|
772
772
|
injectNodes.forEach((node) => {
|
|
@@ -1406,6 +1406,8 @@ function postProcessWxs (el, meta) {
|
|
|
1406
1406
|
}
|
|
1407
1407
|
}
|
|
1408
1408
|
|
|
1409
|
+
const spreadREG = /\{\s*\.\.\.\s*([^,{]+?)\s*\}/g
|
|
1410
|
+
|
|
1409
1411
|
function processAttrs (el, options) {
|
|
1410
1412
|
el.attrsList.forEach((attr) => {
|
|
1411
1413
|
const isTemplateData = el.tag === 'template' && attr.name === 'data'
|
|
@@ -1415,7 +1417,11 @@ function processAttrs (el, options) {
|
|
|
1415
1417
|
if (parsed.hasBinding) {
|
|
1416
1418
|
// 该属性判断用于提供给运行时对于计算属性作为props传递时提出警告
|
|
1417
1419
|
const isProps = isComponentNode(el, options) && !(attr.name === 'class' || attr.name === 'style')
|
|
1418
|
-
|
|
1420
|
+
let result = parsed.result
|
|
1421
|
+
if (isTemplateData) {
|
|
1422
|
+
result = result.replace(spreadREG, '$1')
|
|
1423
|
+
}
|
|
1424
|
+
addExp(el, result, isProps)
|
|
1419
1425
|
if (parsed.replaced) {
|
|
1420
1426
|
modifyAttr(el, attr.name, needWrap ? parsed.val.slice(1, -1) : parsed.val)
|
|
1421
1427
|
}
|
|
@@ -1878,9 +1884,11 @@ function getVirtualHostRoot (options, meta) {
|
|
|
1878
1884
|
function processShow (el, options, root) {
|
|
1879
1885
|
// 开启 virtualhost 全部走 props 传递处理
|
|
1880
1886
|
// 未开启 virtualhost 直接绑定 display:none 到节点上
|
|
1881
|
-
let show = getAndRemoveAttr(el, config[mode].directive.show)
|
|
1887
|
+
let { val: show, has } = getAndRemoveAttr(el, config[mode].directive.show)
|
|
1882
1888
|
if (mode === 'swan') show = wrapMustache(show)
|
|
1883
|
-
|
|
1889
|
+
if (has && show === undefined) {
|
|
1890
|
+
error$1(`Attrs ${config[mode].directive.show} should have a value `)
|
|
1891
|
+
}
|
|
1884
1892
|
if (options.hasVirtualHost) {
|
|
1885
1893
|
if (options.isComponent && el.parent === root && isRealNode(el)) {
|
|
1886
1894
|
if (show !== undefined) {
|
|
@@ -1911,7 +1919,7 @@ function processShow (el, options, root) {
|
|
|
1911
1919
|
oldStyle = oldStyle ? oldStyle + ';' : ''
|
|
1912
1920
|
addAttrs(el, [{
|
|
1913
1921
|
name: 'style',
|
|
1914
|
-
value: `${oldStyle}{{${showExp}
|
|
1922
|
+
value: `${oldStyle}{{${showExp}?'':'display:none;'}}`
|
|
1915
1923
|
}])
|
|
1916
1924
|
}
|
|
1917
1925
|
}
|
|
@@ -2106,15 +2114,12 @@ function processElement (el, root, options, meta) {
|
|
|
2106
2114
|
processIf(el)
|
|
2107
2115
|
processFor(el)
|
|
2108
2116
|
processRef(el, options, meta)
|
|
2117
|
+
processClass(el, meta)
|
|
2118
|
+
processStyle(el, meta)
|
|
2119
|
+
processBindEvent(el, options)
|
|
2109
2120
|
|
|
2110
2121
|
if (!pass) {
|
|
2111
|
-
processClass(el, meta)
|
|
2112
|
-
processStyle(el, meta)
|
|
2113
2122
|
processShow(el, options, root)
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
if (!pass) {
|
|
2117
|
-
processBindEvent(el, options)
|
|
2118
2123
|
processComponentIs(el, options)
|
|
2119
2124
|
}
|
|
2120
2125
|
|
|
@@ -2400,7 +2405,7 @@ function genNode (node) {
|
|
|
2400
2405
|
* @returns
|
|
2401
2406
|
*/
|
|
2402
2407
|
function parseOptionChain (str) {
|
|
2403
|
-
const wxsName = `${
|
|
2408
|
+
const wxsName = `${optionalChainWxsName}.g`
|
|
2404
2409
|
let optionsRes
|
|
2405
2410
|
while (optionsRes = /\?\./.exec(str)) {
|
|
2406
2411
|
const strLength = str.length
|
|
@@ -2550,8 +2555,8 @@ function parseOptionChain (str) {
|
|
|
2550
2555
|
chainKey += `,'${keyValue}'`
|
|
2551
2556
|
}
|
|
2552
2557
|
str = str.slice(0, leftIndex) + `${wxsName}(${chainValue},[${chainKey.slice(1)}])` + str.slice(rightIndex)
|
|
2553
|
-
if (!
|
|
2554
|
-
|
|
2558
|
+
if (!hasOptionalChain) {
|
|
2559
|
+
hasOptionalChain = true
|
|
2555
2560
|
}
|
|
2556
2561
|
}
|
|
2557
2562
|
return str
|
|
@@ -27,7 +27,7 @@ module.exports = function (raw) {
|
|
|
27
27
|
const hasComment = queryObj.hasComment
|
|
28
28
|
const isNative = queryObj.isNative
|
|
29
29
|
const hasScoped = queryObj.hasScoped
|
|
30
|
-
const moduleId = queryObj.moduleId || mpx.pathHash(resourcePath)
|
|
30
|
+
const moduleId = queryObj.moduleId || '_' + mpx.pathHash(resourcePath)
|
|
31
31
|
|
|
32
32
|
let optimizeRenderLevel = 0
|
|
33
33
|
for (const rule of optimizeRenderRules) {
|
|
@@ -80,6 +80,12 @@ module.exports = function (raw) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
const result = compiler.serialize(ast)
|
|
84
|
+
|
|
85
|
+
if (isNative) {
|
|
86
|
+
return result
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
let resultSource = ''
|
|
84
90
|
|
|
85
91
|
for (const module in meta.wxsModuleMap) {
|
|
@@ -87,12 +93,6 @@ module.exports = function (raw) {
|
|
|
87
93
|
resultSource += `var ${module} = require(${loaderUtils.stringifyRequest(this, src)});\n`
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
const result = compiler.serialize(ast)
|
|
91
|
-
|
|
92
|
-
if (isNative) {
|
|
93
|
-
return result
|
|
94
|
-
}
|
|
95
|
-
|
|
96
96
|
resultSource += `
|
|
97
97
|
global.currentInject = {
|
|
98
98
|
moduleId: ${JSON.stringify(moduleId)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.33",
|
|
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": "5a8b6accc9462d4c9a35e06689a6a84903d47c52"
|
|
86
86
|
}
|