@mpxjs/webpack-plugin 2.9.15 → 2.9.17

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/index.js CHANGED
@@ -365,13 +365,18 @@ class MpxWebpackPlugin {
365
365
  if (this.options.writeMode === 'changed') {
366
366
  const writedFileContentMap = new Map()
367
367
  const originalWriteFile = compiler.outputFileSystem.writeFile
368
- compiler.outputFileSystem.writeFile = (filePath, content, callback) => {
368
+ // fs.writeFile(file, data[, options], callback)
369
+ compiler.outputFileSystem.writeFile = (filePath, content, ...args) => {
369
370
  const lastContent = writedFileContentMap.get(filePath)
370
371
  if (Buffer.isBuffer(lastContent) ? lastContent.equals(content) : lastContent === content) {
371
- return callback()
372
+ const callback = args[args.length - 1]
373
+ if (typeof callback === 'function') {
374
+ callback()
375
+ }
376
+ return
372
377
  }
373
378
  writedFileContentMap.set(filePath, content)
374
- originalWriteFile(filePath, content, callback)
379
+ originalWriteFile(filePath, content, ...args)
375
380
  }
376
381
  }
377
382
 
@@ -1288,7 +1293,7 @@ class MpxWebpackPlugin {
1288
1293
  target = expr.object
1289
1294
  }
1290
1295
 
1291
- if (!matchCondition(resourcePath, this.options.transMpxRules) || resourcePath.indexOf('@mpxjs') !== -1 || !target || mode === srcMode) return
1296
+ if (!matchCondition(resourcePath, this.options.transMpxRules) || resourcePath.indexOf('node_modules/@mpxjs') !== -1 || !target || mode === srcMode) return
1292
1297
 
1293
1298
  const type = target.name
1294
1299
  const name = type === 'wx' ? 'mpx' : 'createFactory'
@@ -201,19 +201,30 @@ module.exports = function getSpec ({ warn, error }) {
201
201
  {
202
202
  // 样式类名绑定
203
203
  test: /^(class|wx:class)$/,
204
- web ({ value }, { el }) {
205
- if (el.isClassParsed) {
206
- return false
207
- }
204
+ web ({ name, value }, { el }) {
205
+ if (el.classMerged) return false
208
206
  const classBinding = []
209
- el.isClassParsed = true
210
- el.attrsList.filter(item => this.test.test(item.name)).forEach((item) => {
211
- const parsed = parseMustacheWithContext(item.value)
212
- classBinding.push(parsed.result)
207
+ el.attrsList.filter(item => this.test.test(item.name)).forEach(({ name, value }) => {
208
+ const parsed = parseMustacheWithContext(value)
209
+ if (name === 'wx:class') {
210
+ classBinding.push(parsed.result)
211
+ } else if (name === 'class' && parsed.hasBinding === true) {
212
+ el.classMerged = true
213
+ classBinding.push(parsed.result)
214
+ }
213
215
  })
214
- return {
215
- name: ':class',
216
- value: `[${classBinding}]`
216
+
217
+ if (el.classMerged) {
218
+ return {
219
+ name: ':class',
220
+ value: `[${classBinding}]`
221
+ }
222
+ } else if (name === 'wx:class') {
223
+ // 对于纯静态class不做合并转换
224
+ return {
225
+ name: ':class',
226
+ value: classBinding[0]
227
+ }
217
228
  }
218
229
  }
219
230
  },
@@ -50,6 +50,11 @@
50
50
  url: this.url
51
51
  })
52
52
  break
53
+ case 'switchTab':
54
+ mpx.switchTab && mpx.switchTab({
55
+ url: this.url
56
+ })
57
+ break
53
58
  }
54
59
  }
55
60
  })
@@ -142,4 +142,7 @@
142
142
  display block
143
143
  position relative
144
144
  resize none
145
+ border: none
146
+ outline: none
147
+ background: transparent
145
148
  </style>
@@ -261,6 +261,7 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
261
261
  global.__mpxAppCbs.error.forEach((cb) => {
262
262
  cb.apply(null, args)
263
263
  })
264
+ console.error(...args)
264
265
  } else if (fromVue) {
265
266
  throw args[0]
266
267
  }
@@ -1715,7 +1715,7 @@ function processWebExternalClassesHack (el, options) {
1715
1715
 
1716
1716
  addAttrs(el, [{
1717
1717
  name: ':class',
1718
- value: `[${replacements.join(',')}]`
1718
+ value: `[${replacements}]`
1719
1719
  }])
1720
1720
  }
1721
1721
  }
@@ -1742,7 +1742,7 @@ function processWebExternalClassesHack (el, options) {
1742
1742
 
1743
1743
  addAttrs(el, [{
1744
1744
  name: ':' + classLikeAttrName,
1745
- value: `[${replacements.join(',')}].join(' ')`
1745
+ value: `[${replacements}].join(' ')`
1746
1746
  }])
1747
1747
  }
1748
1748
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.9.15",
3
+ "version": "2.9.17",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -83,5 +83,5 @@
83
83
  "engines": {
84
84
  "node": ">=14.14.0"
85
85
  },
86
- "gitHead": "f3dcf3425dc3e0ad2378b2f35ca020aa9cdd1fb2"
86
+ "gitHead": "80dd826352ab7178952f6ac1f2d7dbcf610fe6cf"
87
87
  }