@mpxjs/webpack-plugin 2.7.3 → 2.7.4

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.
@@ -1,29 +1,32 @@
1
1
  const babylon = require('@babel/parser')
2
2
  const t = require('@babel/types')
3
+ const traverse = require('@babel/traverse').default
3
4
  const generate = require('@babel/generator').default
4
5
 
5
6
  module.exports = function transDynamicClassExpr (expr, { error } = {}) {
6
7
  try {
7
- const ast = babylon.parseExpression(expr, {
8
+ const ast = babylon.parse(expr, {
8
9
  plugins: [
9
10
  'objectRestSpread'
10
11
  ]
11
12
  })
12
- if (t.isObjectExpression(ast)) {
13
- ast.properties.forEach((property) => {
14
- if (t.isObjectProperty(property) && !property.computed) {
15
- const propertyName = property.key.name || property.key.value
16
- if (/-/.test(propertyName)) {
17
- if (/\$/.test(propertyName)) {
18
- error && error(`Dynamic classname [${propertyName}] is not supported, which includes [-] char and [$] char at the same time.`)
19
- } else {
20
- property.key = t.identifier(propertyName.replace(/-/g, '$$') + 'MpxDash')
13
+ traverse(ast, {
14
+ ObjectExpression (path) {
15
+ path.node.properties.forEach((property) => {
16
+ if (t.isObjectProperty(property) && !property.computed) {
17
+ const propertyName = property.key.name || property.key.value
18
+ if (/-/.test(propertyName)) {
19
+ if (/\$/.test(propertyName)) {
20
+ error && error(`Dynamic classname [${propertyName}] is not supported, which includes [-] char and [$] char at the same time.`)
21
+ } else {
22
+ property.key = t.identifier(propertyName.replace(/-/g, '$$') + 'MpxDash')
23
+ }
21
24
  }
22
25
  }
23
- }
24
- })
25
- }
26
- return generate(ast, {
26
+ })
27
+ }
28
+ })
29
+ return generate(ast.program.body[0].expression, {
27
30
  compact: true
28
31
  }).code
29
32
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.7.3",
3
+ "version": "2.7.4",
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": "0cb7ce760316aa22f7c96ba8561a96f3eab2b8d6"
83
+ "gitHead": "4b78885a767a52eb0a970d3721f0c63cf9817c29"
84
84
  }