@mpxjs/webpack-plugin 2.8.28-beta.1 → 2.8.28-beta.3

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.
@@ -76,13 +76,6 @@ class DynamicEntryDependency extends NullDependency {
76
76
 
77
77
  const key = [resource, filename].join('|')
78
78
 
79
- mpx.collectDynamicEntryInfo({
80
- resource,
81
- packageName,
82
- filename,
83
- entryType
84
- })
85
-
86
79
  if (alreadyOutputted) {
87
80
  const addEntryPromise = mpx.addEntryPromiseMap.get(key)
88
81
  if (addEntryPromise) {
@@ -111,6 +104,12 @@ class DynamicEntryDependency extends NullDependency {
111
104
  .catch(err => callback(err))
112
105
 
113
106
  mpx.addEntryPromiseMap.set(key, addEntryPromise)
107
+ mpx.collectDynamicEntryInfo({
108
+ resource,
109
+ packageName,
110
+ filename,
111
+ entryType
112
+ })
114
113
  }
115
114
  }
116
115
  ], callback)
@@ -24,8 +24,9 @@ function objectKeys (obj) {
24
24
  var shift = false
25
25
  for (var i = 1; i < objStr.length - 1; i++) {
26
26
  var item = objStr[i]
27
+ var lastItem = objStr[i - 1]
27
28
  if (inKey) {
28
- if (item === ':') {
29
+ if (item === ':' && lastItem === '"') {
29
30
  keys.push(key.slice(1, -1))
30
31
  key = ''
31
32
  inKey = false
@@ -93,18 +94,53 @@ function isDef (v) {
93
94
  return v !== undefined && v !== null
94
95
  }
95
96
 
97
+ var escapeMap = {
98
+ '(': '_pl_',
99
+ ')': '_pr_',
100
+ '[': '_bl_',
101
+ ']': '_br_',
102
+ '{': '_cl_',
103
+ '#': '_h_',
104
+ '!': '_i_',
105
+ '/': '_s_',
106
+ '.': '_d_',
107
+ ':': '_c_',
108
+ ',': '_2c_',
109
+ '%': '_p_',
110
+ // wxs can not use '\'' as key
111
+ // wxs环境中'\''!=="'",此文件不能格式化,否则会导致程序错误
112
+ "'": '_q_',
113
+ // wxs can not use '"' as key
114
+ '"': '_dq_',
115
+ '+': '_a_',
116
+ '$': '_si_'
117
+ }
118
+
119
+ var escapeReg = genRegExp('[()[\]{}#!/.:,%\'"+$]', 'g')
120
+
121
+ function mpEscape (str) {
122
+ return str.replace(escapeReg, function (match) {
123
+ if (escapeMap[match]) return escapeMap[match]
124
+ // fix wxs can not use '}' as key
125
+ if (match === '}') return '_cr_'
126
+ // unknown escaped
127
+ return '_u_'
128
+ })
129
+ }
130
+
131
+
96
132
  function stringifyDynamicClass (value) {
97
- if (!value) return ''
98
133
  if (isArray(value)) {
99
- return stringifyArray(value)
100
- }
101
- if (isObject(value)) {
102
- return stringifyObject(value)
134
+ value = stringifyArray(value)
135
+ } else if (isObject(value)) {
136
+ value = stringifyObject(value)
103
137
  }
138
+
104
139
  if (typeof value === 'string') {
105
- return value
140
+ return mpEscape(value)
141
+ } else {
142
+ return ''
106
143
  }
107
- return ''
108
144
  }
109
145
 
110
146
  function stringifyArray (value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.8.28-beta.1",
3
+ "version": "2.8.28-beta.3",
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": "07476d16af98cf988302ecb118fc4fb787a8873f"
85
+ "gitHead": "17e31567bab825b2fb7b96f30e08d92fe1cc1038"
86
86
  }