@@ -4,7 +4,7 @@ const t = require('@babel/types')
44const generate = require ( '@babel/generator' ) . default
55const parseRequest = require ( '../utils/parse-request' )
66const isEmptyObject = require ( '../utils/is-empty-object' )
7- const chainAssign = require ( '../utils/chain-assign ' )
7+ const mergeVisitors = require ( '../utils/merge-visitors ' )
88const parseQuery = require ( 'loader-utils' ) . parseQuery
99
1010module . exports = function ( content ) {
@@ -31,7 +31,7 @@ module.exports = function (content) {
3131 ' __mpx_args__[i] = arguments[i];\n' +
3232 '}'
3333 ) . program . body
34- chainAssign ( visitor , {
34+ mergeVisitors ( visitor , {
3535 Identifier ( path ) {
3636 if ( path . node . name === 'arguments' ) {
3737 path . node . name = '__mpx_args__'
@@ -66,7 +66,7 @@ module.exports = function (content) {
6666 }
6767
6868 if ( mode !== 'wx' ) {
69- chainAssign ( visitor , {
69+ mergeVisitors ( visitor , {
7070 CallExpression ( path ) {
7171 const callee = path . node . callee
7272 if ( t . isIdentifier ( callee ) && callee . name === 'getRegExp' ) {
@@ -81,7 +81,7 @@ module.exports = function (content) {
8181 }
8282
8383 if ( mode === 'dd' ) {
84- chainAssign ( visitor , {
84+ mergeVisitors ( visitor , {
8585 MemberExpression ( path ) {
8686 const property = path . node . property
8787 if (
@@ -96,11 +96,14 @@ module.exports = function (content) {
9696 }
9797
9898 if ( ! module . wxs ) {
99- chainAssign ( visitor , {
99+ mergeVisitors ( visitor , {
100100 MemberExpression ( path ) {
101+ if ( ! t . isMemberExpression ( path . node ) ) {
102+ return
103+ }
101104 const property = path . node . property
102105 if (
103- ( property . name === 'constructor' || property . value === 'constructor' ) &&
106+ property && ( property . name === 'constructor' || property . value === 'constructor' ) &&
104107 ! ( t . isMemberExpression ( path . parent ) && path . parentKey === 'object' )
105108 ) {
106109 path . replaceWith ( t . memberExpression ( path . node , t . identifier ( 'name' ) ) )
0 commit comments