@@ -47,7 +47,6 @@ module.exports = function ({types: t}) {
47
47
// collect private functions and replace them with `window.PACKAGE._._func = function (args) {...}`
48
48
} else if ( t . isFunctionDeclaration ( node ) && t . isIdentifier ( node . id ) ) {
49
49
if ( node . id . name === '_zk' ) return ;
50
- // if (node.id.name === 'echoGx') return;
51
50
privateFuncs . add ( node . id . name ) ;
52
51
funcCallCount . set ( node . id . name , 0 ) ;
53
52
path . get ( 'body' ) [ index ] . replaceWith (
@@ -124,7 +123,6 @@ module.exports = function ({types: t}) {
124
123
const left = assignPath . node . left ,
125
124
right = assignPath . node . right ;
126
125
// case: FUNC.x = x -> window.PACKAGE._.FUNC.x = x
127
- // FIXME: useless
128
126
if ( t . isMemberExpression ( left ) ) {
129
127
const object = left . object ;
130
128
if ( t . isIdentifier ( object ) && privateFuncs . has ( object . name ) ) {
@@ -138,16 +136,6 @@ module.exports = function ({types: t}) {
138
136
assignPath . node . right = createNestedMemberExpression ( [ right . name , ...dir ] ) ;
139
137
}
140
138
} ,
141
- // FIXME: useless
142
- // MemberExpression(memberPath) {
143
- // const { object, property } = memberPath.node,
144
- // callee = object.callee;
145
- // // case: FUNC.x = y -> window.PACKAGE._.FUNC.x = y
146
- // if (t.isIdentifier(callee) && privateFuncs.has(callee.name)) {
147
- // funcCallCount.set(callee.name, funcCallCount.get(callee.name) + 1);
148
- // memberPath = createNestedMemberExpression([callee.name, ...dir]);
149
- // }
150
- // },
151
139
ConditionalExpression ( condPath ) {
152
140
const { test, consequent, alternate } = condPath . node ;
153
141
// TODO: test ?
@@ -183,10 +171,11 @@ module.exports = function ({types: t}) {
183
171
} ,
184
172
ObjectExpression ( objectPath ) {
185
173
objectPath . node . properties . forEach ( ( property ) => {
174
+ const { key, value} = property ;
186
175
// case: x = { x: FUNC } -> x = { x: window.PACKAGE._.FUNC }
187
176
// case: x.x = FUNC -> x.x = window.PACKAGE._.FUNC
188
- if ( t . isIdentifier ( property . value ) && privateFuncs . has ( property . value . name ) ) {
189
- funcCallCount . set ( property . value . name , funcCallCount . get ( property . value . name ) + 1 ) ;
177
+ if ( t . isIdentifier ( value ) && privateFuncs . has ( value . name ) ) {
178
+ funcCallCount . set ( value . name , funcCallCount . get ( value . name ) + 1 ) ;
190
179
property . value = createNestedMemberExpression ( [ property . value . name , ...dir ] ) ;
191
180
}
192
181
} ) ;
0 commit comments