@mpxjs/webpack-plugin 2.7.49 → 2.7.50-alpha.2

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.
@@ -1989,12 +1989,11 @@ function processAtMode (el) {
1989
1989
  return
1990
1990
  }
1991
1991
 
1992
- const conditionMap = {}
1993
-
1992
+ const conditionMap = new Map()
1994
1993
  modeStr.split('|').forEach(item => {
1995
1994
  const arr = item.split(':')
1996
- const key = arr[0] || mode
1997
- conditionMap[key] = arr.slice(1)
1995
+ const key = arr[0] || 'noMode'
1996
+ conditionMap.set(key, arr.slice(1))
1998
1997
  })
1999
1998
 
2000
1999
  const modeArr = Object.keys(conditionMap)
@@ -2002,19 +2001,33 @@ function processAtMode (el) {
2002
2001
  if (modeArr.every(i => isValidMode(i))) {
2003
2002
  const attrValue = getAndRemoveAttr(el, attrName).val
2004
2003
  const replacedAttrName = attrArr.join('@')
2005
-
2006
2004
  const processedAttr = { name: replacedAttrName, value: attrValue }
2007
- if (modeArr.includes(mode) && (!conditionMap[mode].length || conditionMap[mode].includes(env))) {
2008
- if (!replacedAttrName) {
2009
- el._atModeStatus = 'match'
2005
+
2006
+ for (let [defineMode, defineEnvArr] of conditionMap.entries()) {
2007
+ if (defineMode === 'noMode' || defineMode === mode) {
2008
+ // 命中 env 规则(没有定义env 或者定义的envArr包含当前env)
2009
+ if (!defineEnvArr.length || defineEnvArr.includes(env)) {
2010
+ if (!replacedAttrName) {
2011
+ // 若defineMode 为 noMode,则不论是element,还是attr,都需要经过规则转换
2012
+ if (defineMode !== 'noMode') {
2013
+ el._atModeStatus = 'match'
2014
+ }
2015
+ } else {
2016
+ // 如果命中了指定的mode,则先存在el上,等跑完转换后再挂回去
2017
+ el.noTransAttrs ? el.noTransAttrs.push(processedAttr) : el.noTransAttrs = [processedAttr]
2018
+ }
2019
+ // 命中mode,命中env,完成匹配,直接退出
2020
+ break
2021
+ } else if (!replacedAttrName) {
2022
+ // 命中mode规则,没有命中当前env规则,设置为 'mismatch'
2023
+ el._atModeStatus = 'mismatch'
2024
+ }
2025
+ } else if (!replacedAttrName) {
2026
+ // 没有命中当前mode规则,设置为 'mismatch'
2027
+ el._atModeStatus = 'mismatch'
2010
2028
  } else {
2011
- // 如果命中了指定的mode,则先存在el上,等跑完转换后再挂回去
2012
- el.noTransAttrs ? el.noTransAttrs.push(processedAttr) : el.noTransAttrs = [processedAttr]
2029
+ // 如果没命中指定的mode,则该属性删除
2013
2030
  }
2014
- } else if (!replacedAttrName) {
2015
- el._atModeStatus = 'mismatch'
2016
- } else {
2017
- // 如果没命中指定的mode,则该属性删除
2018
2031
  }
2019
2032
  }
2020
2033
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.7.49",
3
+ "version": "2.7.50-alpha.2",
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": "d24eb21aeb7b11087d5aaaffb1047e7344bfe9cf"
83
+ "gitHead": "1f11736feeec1ad1eace01c32f8b70b296a6896b"
84
84
  }