@@ -76,18 +76,35 @@ function decorateNodePathTraverse(plugin, trace) {
7676 for ( const name in visitors ) {
7777 if ( typeof visitors [ name ] === 'function' ) {
7878 const fn = visitors [ name ] ;
79- newVisitors [ name ] = function ( ) {
80- trace . startTraversePlugin ( name ) ;
81- fn ( ...arguments ) ;
79+ newVisitors [ name ] = function ( path , ... rest ) {
80+ trace . startTraversePlugin ( name , path . node . traceID ) ;
81+ fn ( path , ...rest ) ;
8282 trace . endTraversePlugin ( name ) ;
8383 } ;
8484 } else if ( typeof visitors [ name ] === 'object' ) {
85- debugger
85+ const obj = visitors [ name ] ;
86+
87+ if ( obj . enter ) {
88+ obj . enter = obj . enter . map ( fn => function ( path , ...rest ) {
89+ trace . startTraversePlugin ( name , path . node . traceID ) ;
90+ fn ( path , ...rest ) ;
91+ trace . endTraversePlugin ( name ) ;
92+ } )
93+ }
94+
95+ if ( obj . exit ) {
96+ obj . exit = obj . exit . map ( fn => function ( path , ...rest ) {
97+ trace . startTraversePlugin ( name , path . node . traceID ) ;
98+ fn ( path , ...rest ) ;
99+ trace . endTraversePlugin ( name ) ;
100+ } )
101+ }
102+
103+ newVisitors [ name ] = obj ;
86104 }
87105
88106 }
89107
90- visitors = newVisitors ;
91108 oldTraverse . call ( this , newVisitors , ...rest ) ;
92109
93110 }
@@ -169,9 +186,9 @@ self.onmessage = function(msg) {
169186 config . sourceMaps = true ;
170187
171188 config . wrapPluginVisitorMethod = ( pluginAlias , visitorType , callback ) => {
172- return ( ...args ) => {
173- trace . enterPlugin ( pluginAlias ) ;
174- callback ( ...args ) ;
189+ return ( path , ...rest ) => {
190+ trace . enterPlugin ( pluginAlias , path . node . traceID ) ;
191+ callback ( path , ...rest ) ;
175192 trace . leavePlugin ( pluginAlias ) ;
176193 }
177194 } ;
0 commit comments