@mpxjs/webpack-plugin 2.9.32 → 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.
@@ -104,7 +104,7 @@ let env
104
104
  let platformGetTagNamespace
105
105
  let filePath
106
106
  let refId
107
- let haveOptionChain = false
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 optionsChainWxsPath = '~' + normalize.lib('runtime/oc.wxs')
169
- const optionsChainWxsName = '__oc__'
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
- haveOptionChain = false
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 (haveOptionChain) {
769
- injectWxs(meta, optionsChainWxsName, optionsChainWxsPath)
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
- addExp(el, parsed.result, isProps)
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
  }
@@ -2108,15 +2114,12 @@ function processElement (el, root, options, meta) {
2108
2114
  processIf(el)
2109
2115
  processFor(el)
2110
2116
  processRef(el, options, meta)
2117
+ processClass(el, meta)
2118
+ processStyle(el, meta)
2119
+ processBindEvent(el, options)
2111
2120
 
2112
2121
  if (!pass) {
2113
- processClass(el, meta)
2114
- processStyle(el, meta)
2115
2122
  processShow(el, options, root)
2116
- }
2117
-
2118
- if (!pass) {
2119
- processBindEvent(el, options)
2120
2123
  processComponentIs(el, options)
2121
2124
  }
2122
2125
 
@@ -2402,7 +2405,7 @@ function genNode (node) {
2402
2405
  * @returns
2403
2406
  */
2404
2407
  function parseOptionChain (str) {
2405
- const wxsName = `${optionsChainWxsName}.g`
2408
+ const wxsName = `${optionalChainWxsName}.g`
2406
2409
  let optionsRes
2407
2410
  while (optionsRes = /\?\./.exec(str)) {
2408
2411
  const strLength = str.length
@@ -2552,8 +2555,8 @@ function parseOptionChain (str) {
2552
2555
  chainKey += `,'${keyValue}'`
2553
2556
  }
2554
2557
  str = str.slice(0, leftIndex) + `${wxsName}(${chainValue},[${chainKey.slice(1)}])` + str.slice(rightIndex)
2555
- if (!haveOptionChain) {
2556
- haveOptionChain = true
2558
+ if (!hasOptionalChain) {
2559
+ hasOptionalChain = true
2557
2560
  }
2558
2561
  }
2559
2562
  return str
@@ -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.32",
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": "61ac5a85a2b75304d8b989d4291b4f606f50d82f"
85
+ "gitHead": "5a8b6accc9462d4c9a35e06689a6a84903d47c52"
86
86
  }