@mpxjs/webpack-plugin 2.8.25-alpha → 2.8.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.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/lib/config.js +0 -14
  3. package/lib/dependencies/DynamicEntryDependency.js +11 -16
  4. package/lib/dependencies/ResolveDependency.js +0 -4
  5. package/lib/index.js +28 -44
  6. package/lib/json-compiler/index.js +8 -1
  7. package/lib/loader.js +0 -40
  8. package/lib/platform/template/wx/component-config/button.js +2 -14
  9. package/lib/platform/template/wx/component-config/component.js +2 -2
  10. package/lib/platform/template/wx/component-config/image.js +0 -4
  11. package/lib/platform/template/wx/component-config/input.js +0 -4
  12. package/lib/platform/template/wx/component-config/rich-text.js +0 -4
  13. package/lib/platform/template/wx/component-config/scroll-view.js +0 -4
  14. package/lib/platform/template/wx/component-config/switch.js +0 -4
  15. package/lib/platform/template/wx/component-config/text.js +0 -4
  16. package/lib/platform/template/wx/component-config/textarea.js +0 -5
  17. package/lib/platform/template/wx/component-config/view.js +0 -4
  18. package/lib/platform/template/wx/index.js +11 -131
  19. package/lib/resolve-loader.js +1 -4
  20. package/lib/style-compiler/index.js +1 -1
  21. package/lib/template-compiler/compiler.js +74 -60
  22. package/lib/wxss/loader.js +3 -3
  23. package/package.json +3 -6
  24. package/lib/dependencies/AddEntryDependency.js +0 -24
  25. package/lib/runtime/components/tenon/getInnerListeners.js +0 -314
  26. package/lib/runtime/components/tenon/tenon-button.vue +0 -305
  27. package/lib/runtime/components/tenon/tenon-image.vue +0 -61
  28. package/lib/runtime/components/tenon/tenon-input.vue +0 -104
  29. package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -21
  30. package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -124
  31. package/lib/runtime/components/tenon/tenon-switch.vue +0 -91
  32. package/lib/runtime/components/tenon/tenon-text-area.vue +0 -77
  33. package/lib/runtime/components/tenon/tenon-text.vue +0 -64
  34. package/lib/runtime/components/tenon/tenon-view.vue +0 -93
  35. package/lib/runtime/optionProcessor.tenon.js +0 -388
  36. package/lib/style-compiler/plugins/hm.js +0 -20
  37. package/lib/tenon/index.js +0 -104
  38. package/lib/tenon/processJSON.js +0 -356
  39. package/lib/tenon/processScript.js +0 -263
  40. package/lib/tenon/processStyles.js +0 -21
  41. package/lib/tenon/processTemplate.js +0 -133
  42. package/lib/utils/fix-swan-relative.js +0 -6
  43. package/lib/utils/get-relative-path.js +0 -25
@@ -4,29 +4,20 @@ const getComponentConfigs = require('./component-config')
4
4
  const normalizeComponentRules = require('../normalize-component-rules')
5
5
  const isValidIdentifierStr = require('../../../utils/is-valid-identifier-str')
6
6
  const templateCompiler = require('../../../template-compiler/compiler')
7
- const parseMustache = templateCompiler.parseMustache
7
+ const parseMustacheWithContext = templateCompiler.parseMustacheWithContext
8
8
  const stringifyWithResolveComputed = templateCompiler.stringifyWithResolveComputed
9
9
  const normalize = require('../../../utils/normalize')
10
10
 
11
11
  module.exports = function getSpec ({ warn, error }) {
12
12
  const spec = {
13
- supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd', 'tenon'],
13
+ supportedModes: ['ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd'],
14
14
  // props预处理
15
15
  preProps: [],
16
16
  // props后处理
17
17
  postProps: [
18
18
  {
19
19
  web ({ name, value }) {
20
- const parsed = parseMustache(value)
21
- if (parsed.hasBinding) {
22
- return {
23
- name: name === 'animation' ? 'v-' + name : ':' + name,
24
- value: parsed.result
25
- }
26
- }
27
- },
28
- tenon ({ name, value }) {
29
- const parsed = parseMustache(value)
20
+ const parsed = parseMustacheWithContext(value)
30
21
  if (parsed.hasBinding) {
31
22
  return {
32
23
  name: name === 'animation' ? 'v-' + name : ':' + name,
@@ -43,7 +34,7 @@ module.exports = function getSpec ({ warn, error }) {
43
34
  test: 'wx:for',
44
35
  swan (obj, data) {
45
36
  const attrsMap = data.el.attrsMap
46
- const parsed = parseMustache(obj.value)
37
+ const parsed = parseMustacheWithContext(obj.value)
47
38
  let listName = parsed.result
48
39
  const el = data.el
49
40
 
@@ -57,7 +48,7 @@ module.exports = function getSpec ({ warn, error }) {
57
48
  }
58
49
 
59
50
  if (keyName) {
60
- const parsed = parseMustache(keyName)
51
+ const parsed = parseMustacheWithContext(keyName)
61
52
  if (parsed.hasBinding) {
62
53
  // keyStr = ` trackBy ${parsed.result.slice(1, -1)}`
63
54
  } else if (keyName === '*this') {
@@ -87,17 +78,7 @@ module.exports = function getSpec ({ warn, error }) {
87
78
  }
88
79
  },
89
80
  web ({ value }, { el }) {
90
- const parsed = parseMustache(value)
91
- const attrsMap = el.attrsMap
92
- const itemName = attrsMap['wx:for-item'] || 'item'
93
- const indexName = attrsMap['wx:for-index'] || 'index'
94
- return {
95
- name: 'v-for',
96
- value: `(${itemName}, ${indexName}) in ${parsed.result}`
97
- }
98
- },
99
- tenon ({ value }, { el }) {
100
- const parsed = parseMustache(value)
81
+ const parsed = parseMustacheWithContext(value)
101
82
  const attrsMap = el.attrsMap
102
83
  const itemName = attrsMap['wx:for-item'] || 'item'
103
84
  const indexName = attrsMap['wx:for-index'] || 'index'
@@ -130,25 +111,6 @@ module.exports = function getSpec ({ warn, error }) {
130
111
  name: ':key',
131
112
  value
132
113
  }
133
- },
134
- tenon ({ value }, { el }) {
135
- // vue的template中不能包含key,对应于小程序中的block
136
- if (el.tag === 'block') return false
137
- const itemName = el.attrsMap['wx:for-item'] || 'item'
138
- const keyName = value
139
- if (value === '*this') {
140
- value = itemName
141
- } else {
142
- if (isValidIdentifierStr(keyName)) {
143
- value = `${itemName}.${keyName}`
144
- } else {
145
- value = `${itemName}['${keyName}']`
146
- }
147
- }
148
- return {
149
- name: ':key',
150
- value
151
- }
152
114
  }
153
115
  },
154
116
  {
@@ -159,9 +121,6 @@ module.exports = function getSpec ({ warn, error }) {
159
121
  },
160
122
  web () {
161
123
  return false
162
- },
163
- tenon () {
164
- return false
165
124
  }
166
125
  },
167
126
  {
@@ -204,49 +163,6 @@ module.exports = function getSpec ({ warn, error }) {
204
163
  }
205
164
  ]
206
165
  }
207
- },
208
- tenon ({ value }, { el }) {
209
- el.hasEvent = true
210
- const attrsMap = el.attrsMap
211
- const tagRE = /\{\{((?:.|\n|\r)+?)\}\}(?!})/
212
- const stringify = JSON.stringify
213
- const match = tagRE.exec(value)
214
- if (match) {
215
- const modelProp = attrsMap['wx:model-prop'] || 'value'
216
- const modelEvent = attrsMap['wx:model-event'] || 'input'
217
- const modelValuePathRaw = attrsMap['wx:model-value-path']
218
- const modelValuePath = modelValuePathRaw === undefined ? 'value' : modelValuePathRaw
219
- const modelFilter = attrsMap['wx:model-filter']
220
- let modelValuePathArr
221
- try {
222
- modelValuePathArr = JSON5.parse(modelValuePath)
223
- } catch (e) {
224
- if (modelValuePath === '') {
225
- modelValuePathArr = []
226
- } else {
227
- modelValuePathArr = modelValuePath.split('.')
228
- }
229
- }
230
- const modelValue = match[1].trim()
231
- return [
232
- {
233
- name: ':' + modelProp,
234
- value: modelValue
235
- },
236
- {
237
- name: 'mpxModelEvent',
238
- value: modelEvent
239
- },
240
- {
241
- name: 'mpxModelEventId',
242
- value: Math.random().toString(36).slice(3, 11)
243
- },
244
- {
245
- name: '@mpxModel',
246
- value: `__model(${stringifyWithResolveComputed(modelValue)}, $event, ${stringify(modelValuePathArr)}, ${stringify(modelFilter)})`
247
- }
248
- ]
249
- }
250
166
  }
251
167
  },
252
168
  {
@@ -275,15 +191,15 @@ module.exports = function getSpec ({ warn, error }) {
275
191
  const styleBinding = []
276
192
  el.isStyleParsed = true
277
193
  el.attrsList.forEach((item) => {
278
- const parsed = parseMustache(item.value)
194
+ const parsed = parseMustacheWithContext(item.value)
279
195
  if (item.name === 'style') {
280
196
  if (parsed.hasBinding || parsed.result.indexOf('rpx') > -1) {
281
- styleBinding.push(parseMustache(item.value).result)
197
+ styleBinding.push(parseMustacheWithContext(item.value).result)
282
198
  } else {
283
199
  styleBinding.push(JSON.stringify(item.value))
284
200
  }
285
201
  } else if (item.name === 'wx:style') {
286
- styleBinding.push(parseMustache(item.value).result)
202
+ styleBinding.push(parseMustacheWithContext(item.value).result)
287
203
  }
288
204
  })
289
205
  return {
@@ -296,19 +212,11 @@ module.exports = function getSpec ({ warn, error }) {
296
212
  // 样式类名绑定
297
213
  test: /^wx:(class)$/,
298
214
  web ({ value }) {
299
- const parsed = parseMustache(value)
215
+ const parsed = parseMustacheWithContext(value)
300
216
  return {
301
217
  name: ':class',
302
218
  value: parsed.result
303
219
  }
304
- },
305
- tenon ({ name, value }) {
306
- const dir = this.test.exec(name)[1]
307
- const parsed = parseMustache(value)
308
- return {
309
- name: ':' + dir,
310
- value: parsed.result
311
- }
312
220
  }
313
221
  },
314
222
  // 通用指令
@@ -358,18 +266,7 @@ module.exports = function getSpec ({ warn, error }) {
358
266
  },
359
267
  web ({ name, value }) {
360
268
  let dir = this.test.exec(name)[1]
361
- const parsed = parseMustache(value)
362
- if (dir === 'elif') {
363
- dir = 'else-if'
364
- }
365
- return {
366
- name: 'v-' + dir,
367
- value: parsed.result
368
- }
369
- },
370
- tenon ({ name, value }) {
371
- let dir = this.test.exec(name)[1]
372
- const parsed = parseMustache(value)
269
+ const parsed = parseMustacheWithContext(value)
373
270
  if (dir === 'elif') {
374
271
  dir = 'else-if'
375
272
  }
@@ -449,23 +346,6 @@ module.exports = function getSpec ({ warn, error }) {
449
346
  name: rPrefix + rEventName + meta.modifierStr,
450
347
  value
451
348
  }
452
- },
453
- tenon ({ name, value }, { eventRules, el }) {
454
- const match = this.test.exec(name)
455
- const prefix = match[1]
456
- const eventName = match[2]
457
- const modifierStr = match[3] || ''
458
- const meta = {
459
- modifierStr
460
- }
461
- // 记录event监听信息用于后续判断是否需要使用内置基础组件
462
- el.hasEvent = true
463
- const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'web', meta })
464
- const rEventName = runRules(eventRules, eventName, { mode: 'web' })
465
- return {
466
- name: rPrefix + rEventName + meta.modifierStr,
467
- value
468
- }
469
349
  }
470
350
  },
471
351
  // 无障碍
@@ -1,6 +1,3 @@
1
1
  module.exports = function () {
2
- return `
3
- var currentURL = global.currentPagePath
4
- var getRelativePath = require('@mpxjs/webpack-plugin/lib/utils/get-relative-path').getRelativePath
5
- module.exports = __mpx_resolve_path__(${JSON.stringify(this.resource)})`
2
+ return `module.exports = __mpx_resolve_path__(${JSON.stringify(this.resource)})`
6
3
  }
@@ -23,7 +23,7 @@ module.exports = function (css, map) {
23
23
  const transRpxRulesRaw = mpx.transRpxRules
24
24
  const transRpxRules = transRpxRulesRaw ? (Array.isArray(transRpxRulesRaw) ? transRpxRulesRaw : [transRpxRulesRaw]) : []
25
25
 
26
- const transRpxFn = mpx.webConfig && mpx.webConfig.transRpxFn
26
+ const transRpxFn = mpx.webConfig.transRpxFn
27
27
  const testResolveRange = (include = () => true, exclude) => {
28
28
  return matchCondition(this.resourcePath, { include, exclude })
29
29
  }
@@ -967,7 +967,7 @@ function processComponentIs (el, options) {
967
967
 
968
968
  const is = getAndRemoveAttr(el, 'is').val
969
969
  if (is) {
970
- el.is = parseMustache(is).result
970
+ el.is = parseMustacheWithContext(is).result
971
971
  } else {
972
972
  warn$1('<component> tag should have attrs[is].')
973
973
  }
@@ -979,7 +979,7 @@ function parseFuncStr2 (str) {
979
979
  const funcRE = /^([^()]+)(\((.*)\))?/
980
980
  const match = funcRE.exec(str)
981
981
  if (match) {
982
- const funcName = parseMustache(match[1]).result
982
+ const funcName = parseMustacheWithContext(match[1]).result
983
983
  const hasArgs = !!match[2]
984
984
  let args = match[3] ? `,${match[3]}` : ''
985
985
  const ret = /(,|^)\s*(\$event)\s*(,|$)/.exec(args)
@@ -1163,19 +1163,9 @@ function wrapMustache (val) {
1163
1163
  return val && !tagRE.test(val) ? `{{${val}}}` : val
1164
1164
  }
1165
1165
 
1166
- function parseMustache (raw = '') {
1167
- let replaced = false
1168
- if (tagRE.test(raw)) {
1169
- const ret = []
1170
- let lastLastIndex = 0
1171
- let match
1172
- while (match = tagREG.exec(raw)) {
1173
- const pre = raw.substring(lastLastIndex, match.index)
1174
- if (pre) {
1175
- ret.push(stringify(pre))
1176
- }
1177
- let exp = match[1]
1178
-
1166
+ function parseMustacheWithContext (raw = '') {
1167
+ return parseMustache(raw, (exp) => {
1168
+ if (defs) {
1179
1169
  // eval处理的话,和别的判断条件,比如运行时的判断混用情况下得不到一个结果,还是正则替换
1180
1170
  const defKeys = Object.keys(defs)
1181
1171
  defKeys.forEach((defKey) => {
@@ -1183,42 +1173,70 @@ function parseMustache (raw = '') {
1183
1173
  const defREG = new RegExp(`\\b${defKey}\\b`, 'g')
1184
1174
  if (defRE.test(exp)) {
1185
1175
  exp = exp.replace(defREG, stringify(defs[defKey]))
1186
- replaced = true
1187
1176
  }
1188
1177
  })
1178
+ }
1189
1179
 
1190
- if (i18n) {
1191
- for (const i18nFuncName of i18nFuncNames) {
1192
- const funcNameRE = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`)
1193
- const funcNameREG = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`, 'g')
1194
- if (funcNameRE.test(exp)) {
1195
- if (i18n.useComputed || !i18nFuncName.startsWith('\\$')) {
1196
- const i18nInjectComputedKey = `_i${i18nInjectableComputed.length + 1}`
1197
- i18nInjectableComputed.push(`${i18nInjectComputedKey} () {\nreturn ${exp.trim()}}`)
1198
- exp = i18nInjectComputedKey
1199
- } else {
1200
- exp = exp.replace(funcNameREG, `${i18nModuleName}.$1(null, _l, _fl, `)
1201
- }
1202
- hasI18n = true
1203
- replaced = true
1204
- break
1180
+ if (i18n) {
1181
+ for (const i18nFuncName of i18nFuncNames) {
1182
+ const funcNameRE = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`)
1183
+ const funcNameREG = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`, 'g')
1184
+ if (funcNameRE.test(exp)) {
1185
+ if (i18n.useComputed || !i18nFuncName.startsWith('\\$')) {
1186
+ const i18nInjectComputedKey = `_i${i18nInjectableComputed.length + 1}`
1187
+ i18nInjectableComputed.push(`${i18nInjectComputedKey} () {\nreturn ${exp.trim()}}`)
1188
+ exp = i18nInjectComputedKey
1189
+ } else {
1190
+ exp = exp.replace(funcNameREG, `${i18nModuleName}.$1(null, _l, _fl, `)
1205
1191
  }
1192
+ hasI18n = true
1193
+ break
1206
1194
  }
1207
1195
  }
1196
+ }
1197
+
1198
+ return exp
1199
+ })
1200
+ }
1201
+
1202
+ function parseMustache (raw = '', expHandler = exp => exp, strHandler = str => str) {
1203
+ let replaced = false
1204
+ if (tagRE.test(raw)) {
1205
+ const ret = []
1206
+ let lastLastIndex = 0
1207
+ let match
1208
+ while (match = tagREG.exec(raw)) {
1209
+ const pre = raw.substring(lastLastIndex, match.index)
1210
+ if (pre) {
1211
+ const pre2 = strHandler(pre)
1212
+ if (pre2 !== pre) replaced = true
1213
+ if (pre2) ret.push(stringify(pre2))
1214
+ }
1215
+
1216
+ const exp = match[1].trim()
1217
+ if (exp) {
1218
+ const exp2 = expHandler(exp)
1219
+ if (exp2 !== exp) replaced = true
1220
+ if (exp2) ret.push(`(${exp2})`)
1221
+ }
1208
1222
 
1209
- ret.push(`(${exp.trim()})`)
1210
1223
  lastLastIndex = tagREG.lastIndex
1211
1224
  }
1225
+
1212
1226
  const post = raw.substring(lastLastIndex)
1213
1227
  if (post) {
1214
- ret.push(stringify(post))
1228
+ const post2 = strHandler(post)
1229
+ if (post2 !== post) replaced = true
1230
+ if (post2) ret.push(stringify(post2))
1215
1231
  }
1232
+
1216
1233
  let result
1217
1234
  if (ret.length === 1) {
1218
1235
  result = ret[0]
1219
1236
  } else {
1220
1237
  result = `(${ret.join('+')})`
1221
1238
  }
1239
+
1222
1240
  return {
1223
1241
  result,
1224
1242
  hasBinding: true,
@@ -1226,10 +1244,14 @@ function parseMustache (raw = '') {
1226
1244
  replaced
1227
1245
  }
1228
1246
  }
1247
+
1248
+ const raw2 = strHandler(raw)
1249
+ if (raw2 !== raw) replaced = true
1250
+
1229
1251
  return {
1230
- result: stringify(raw),
1252
+ result: stringify(raw2),
1231
1253
  hasBinding: false,
1232
- val: raw,
1254
+ val: raw2,
1233
1255
  replaced
1234
1256
  }
1235
1257
  }
@@ -1247,14 +1269,14 @@ function processIf (el) {
1247
1269
  let val = getAndRemoveAttr(el, config[mode].directive.if).val
1248
1270
  if (val) {
1249
1271
  if (mode === 'swan') val = wrapMustache(val)
1250
- const parsed = parseMustache(val)
1272
+ const parsed = parseMustacheWithContext(val)
1251
1273
  el.if = {
1252
1274
  raw: parsed.val,
1253
1275
  exp: parsed.result
1254
1276
  }
1255
1277
  } else if (val = getAndRemoveAttr(el, config[mode].directive.elseif).val) {
1256
1278
  if (mode === 'swan') val = wrapMustache(val)
1257
- const parsed = parseMustache(val)
1279
+ const parsed = parseMustacheWithContext(val)
1258
1280
  el.elseif = {
1259
1281
  raw: parsed.val,
1260
1282
  exp: parsed.result
@@ -1296,7 +1318,7 @@ function processFor (el) {
1296
1318
  }
1297
1319
  } else {
1298
1320
  if (mode === 'swan') val = wrapMustache(val)
1299
- const parsed = parseMustache(val)
1321
+ const parsed = parseMustacheWithContext(val)
1300
1322
  el.for = {
1301
1323
  raw: parsed.val,
1302
1324
  exp: parsed.result
@@ -1408,14 +1430,14 @@ function processAttrs (el, options) {
1408
1430
  const isTemplateData = el.tag === 'template' && attr.name === 'data'
1409
1431
  const needWrap = isTemplateData && mode !== 'swan'
1410
1432
  const value = needWrap ? `{${attr.value}}` : attr.value
1411
- const parsed = parseMustache(value)
1433
+ const parsed = parseMustacheWithContext(value)
1412
1434
  if (parsed.hasBinding) {
1413
1435
  // 该属性判断用于提供给运行时对于计算属性作为props传递时提出警告
1414
1436
  const isProps = isComponentNode(el, options) && !(attr.name === 'class' || attr.name === 'style')
1415
1437
  addExp(el, parsed.result, isProps)
1416
- }
1417
- if (parsed.replaced) {
1418
- modifyAttr(el, attr.name, needWrap ? parsed.val.slice(1, -1) : parsed.val)
1438
+ if (parsed.replaced) {
1439
+ modifyAttr(el, attr.name, needWrap ? parsed.val.slice(1, -1) : parsed.val)
1440
+ }
1419
1441
  }
1420
1442
  })
1421
1443
  }
@@ -1547,7 +1569,7 @@ function processText (el) {
1547
1569
  if (el.type !== 3 || el.isComment) {
1548
1570
  return
1549
1571
  }
1550
- const parsed = parseMustache(el.text)
1572
+ const parsed = parseMustacheWithContext(el.text)
1551
1573
  if (parsed.hasBinding) {
1552
1574
  addExp(el, parsed.result)
1553
1575
  }
@@ -1592,8 +1614,8 @@ function processClass (el, meta) {
1592
1614
  let staticClass = getAndRemoveAttr(el, type).val || ''
1593
1615
  staticClass = staticClass.replace(/\s+/g, ' ')
1594
1616
  if (dynamicClass) {
1595
- const staticClassExp = parseMustache(staticClass).result
1596
- const dynamicClassExp = transDynamicClassExpr(parseMustache(dynamicClass).result, {
1617
+ const staticClassExp = parseMustacheWithContext(staticClass).result
1618
+ const dynamicClassExp = transDynamicClassExpr(parseMustacheWithContext(dynamicClass).result, {
1597
1619
  error: error$1
1598
1620
  })
1599
1621
  addAttrs(el, [{
@@ -1628,8 +1650,8 @@ function processStyle (el, meta) {
1628
1650
  let staticStyle = getAndRemoveAttr(el, type).val || ''
1629
1651
  staticStyle = staticStyle.replace(/\s+/g, ' ')
1630
1652
  if (dynamicStyle) {
1631
- const staticStyleExp = parseMustache(staticStyle).result
1632
- const dynamicStyleExp = parseMustache(dynamicStyle).result
1653
+ const staticStyleExp = parseMustacheWithContext(staticStyle).result
1654
+ const dynamicStyleExp = parseMustacheWithContext(dynamicStyle).result
1633
1655
  addAttrs(el, [{
1634
1656
  name: targetType,
1635
1657
  value: `{{${stringifyModuleName}.stringifyStyle(${staticStyleExp}, ${dynamicStyleExp})}}`
@@ -1870,7 +1892,7 @@ function processShow (el, options, root) {
1870
1892
  if (options.hasVirtualHost) {
1871
1893
  if (options.isComponent && el.parent === root && isRealNode(el)) {
1872
1894
  if (show !== undefined) {
1873
- show = `{{${parseMustache(show).result}&&mpxShow}}`
1895
+ show = `{{${parseMustacheWithContext(show).result}&&mpxShow}}`
1874
1896
  } else {
1875
1897
  show = '{{mpxShow}}'
1876
1898
  }
@@ -1892,7 +1914,7 @@ function processShow (el, options, root) {
1892
1914
 
1893
1915
  function processShowStyle () {
1894
1916
  if (show !== undefined) {
1895
- const showExp = parseMustache(show).result
1917
+ const showExp = parseMustacheWithContext(show).result
1896
1918
  let oldStyle = getAndRemoveAttr(el, 'style').val
1897
1919
  oldStyle = oldStyle ? oldStyle + ';' : ''
1898
1920
  addAttrs(el, [{
@@ -2065,15 +2087,6 @@ function processElement (el, root, options, meta) {
2065
2087
  processComponentGenericsForWeb(el, options, meta)
2066
2088
  return
2067
2089
  }
2068
- if (mode === 'tenon') {
2069
- // 收集内建组件
2070
- processBuiltInComponents(el, meta)
2071
- // 预处理代码维度条件编译
2072
- processIfForWeb(el)
2073
- // processWebExternalClassesHack(el, options)
2074
- // processComponentGenericsForWeb(el, options, meta)
2075
- return
2076
- }
2077
2090
 
2078
2091
  const pass = isNative || processTemplate(el) || processingTemplate
2079
2092
 
@@ -2106,7 +2119,7 @@ function processElement (el, root, options, meta) {
2106
2119
 
2107
2120
  function closeElement (el, meta, options) {
2108
2121
  postProcessAtMode(el)
2109
- if (mode === 'web' || mode === 'tenon') {
2122
+ if (mode === 'web') {
2110
2123
  postProcessWxs(el, meta)
2111
2124
  // 处理代码维度条件编译移除死分支
2112
2125
  postProcessIf(el)
@@ -2220,7 +2233,7 @@ function serialize (root) {
2220
2233
  result += node.text
2221
2234
  }
2222
2235
  }
2223
- if (node.tag === 'wxs' && (mode === 'web' || mode === 'tenon')) {
2236
+ if (node.tag === 'wxs' && mode === 'web') {
2224
2237
  return result
2225
2238
  }
2226
2239
  if (node.type === 1) {
@@ -2385,6 +2398,7 @@ module.exports = {
2385
2398
  makeAttrsMap,
2386
2399
  stringifyAttr,
2387
2400
  parseMustache,
2401
+ parseMustacheWithContext,
2388
2402
  stringifyWithResolveComputed,
2389
2403
  addAttrs
2390
2404
  }
@@ -223,18 +223,18 @@ module.exports = async function loader (content, map, meta) {
223
223
  imports.unshift({
224
224
  type: 'api_import',
225
225
  importName: '___CSS_LOADER_API_IMPORT___',
226
- url: stringifyRequest(this, '!!' + require.resolve('./runtime/api'))
226
+ url: stringifyRequest(this, require.resolve('./runtime/api'))
227
227
  })
228
228
 
229
229
  if (options.sourceMap) {
230
230
  imports.unshift({
231
231
  importName: '___CSS_LOADER_API_SOURCEMAP_IMPORT___',
232
- url: stringifyRequest(this, '!!' + require.resolve('./runtime/sourceMaps'))
232
+ url: stringifyRequest(this, require.resolve('./runtime/sourceMaps'))
233
233
  })
234
234
  } else {
235
235
  imports.unshift({
236
236
  importName: '___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___',
237
- url: stringifyRequest(this, '!!' + require.resolve('./runtime/noSourceMaps'))
237
+ url: stringifyRequest(this, require.resolve('./runtime/noSourceMaps'))
238
238
  })
239
239
  }
240
240
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.8.25-alpha",
3
+ "version": "2.8.27",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
7
7
  ],
8
8
  "author": "donghongping",
9
- "license": "Apache",
9
+ "license": "Apache-2.0",
10
10
  "main": "lib/index.js",
11
11
  "directories": {
12
12
  "lib": "lib"
@@ -27,9 +27,6 @@
27
27
  "@better-scroll/slide": "^2.2.1",
28
28
  "@better-scroll/wheel": "^2.2.1",
29
29
  "@better-scroll/zoom": "^2.2.1",
30
- "@hummer/tenon-dev-server-webpack-plugin": "0.0.2",
31
- "@hummer/tenon-loader": "^1.1.0",
32
- "@hummer/tenon-style-loader": "^0.2.0",
33
30
  "acorn-walk": "^7.2.0",
34
31
  "async": "^2.6.0",
35
32
  "consolidate": "^0.15.1",
@@ -85,5 +82,5 @@
85
82
  "engines": {
86
83
  "node": ">=14.14.0"
87
84
  },
88
- "gitHead": "345dc10820535a06d9aee8d2a1e6cc735ba08882"
85
+ "gitHead": "f5b31d1f4f7602f103e5757f910f267d46bb91b1"
89
86
  }
@@ -1,24 +0,0 @@
1
- const NullDependency = require('webpack/lib/dependencies/NullDependency')
2
-
3
- class AddEntryDependency extends NullDependency {
4
- constructor ({ context, dep, name }) {
5
- super()
6
- this.__addEntryParams = [context, dep, name]
7
- }
8
-
9
- get type () {
10
- return 'mpx add entry'
11
- }
12
-
13
- // updateHash (hash) {
14
- // super.updateHash(hash)
15
- // hash.update(this.childCompileEntryModule.identifier())
16
- // }
17
- }
18
-
19
- AddEntryDependency.Template = class AddEntryDependencyTemplate {
20
- apply () {
21
- }
22
- }
23
-
24
- module.exports = AddEntryDependency