@@ -27,12 +27,12 @@ const genWrappedFunc = ({
2727 // to complete compilation. If this gets invoked and not the subsequent
2828 // call, then our data will be inaccurate, sadly
2929 addEndEvent ( ) ;
30- const normalArgMap = a => wrap ( a , pluginName , smp ) ;
30+ const normalArgMap = ( a ) => wrap ( a , pluginName , smp ) ;
3131 let ret ;
3232 if ( endType === "wrapDone" )
3333 ret = func . apply (
3434 context ,
35- args . map ( a => wrap ( a , pluginName , smp , addEndEvent ) )
35+ args . map ( ( a ) => wrap ( a , pluginName , smp , addEndEvent ) )
3636 ) ;
3737 else if ( endType === "async" ) {
3838 const argsButLast = args . slice ( 0 , args . length - 1 ) ;
@@ -45,7 +45,7 @@ const genWrappedFunc = ({
4545 } )
4646 ) ;
4747 } else if ( endType === "promise" )
48- ret = func . apply ( context , args . map ( normalArgMap ) ) . then ( promiseArg => {
48+ ret = func . apply ( context , args . map ( normalArgMap ) ) . then ( ( promiseArg ) => {
4949 addEndEvent ( ) ;
5050 return promiseArg ;
5151 } ) ;
@@ -56,7 +56,7 @@ const genWrappedFunc = ({
5656} ;
5757
5858const genPluginMethod = ( orig , pluginName , smp , type ) =>
59- function ( method , func ) {
59+ function ( method , func ) {
6060 const timeEventName = pluginName + "/" + type + "/" + method ;
6161 const wrappedFunc = genWrappedFunc ( {
6262 func,
@@ -70,7 +70,7 @@ const genPluginMethod = (orig, pluginName, smp, type) =>
7070 } ;
7171
7272const wrapTap = ( tap , pluginName , smp , type , method ) =>
73- function ( id , func ) {
73+ function ( id , func ) {
7474 const timeEventName = pluginName + "/" + type + "/" + method ;
7575 const wrappedFunc = genWrappedFunc ( {
7676 func,
@@ -83,7 +83,7 @@ const wrapTap = (tap, pluginName, smp, type, method) =>
8383 } ;
8484
8585const wrapTapAsync = ( tapAsync , pluginName , smp , type , method ) =>
86- function ( id , func ) {
86+ function ( id , func ) {
8787 const timeEventName = pluginName + "/" + type + "/" + method ;
8888 const wrappedFunc = genWrappedFunc ( {
8989 func,
@@ -97,7 +97,7 @@ const wrapTapAsync = (tapAsync, pluginName, smp, type, method) =>
9797 } ;
9898
9999const wrapTapPromise = ( tapPromise , pluginName , smp , type , method ) =>
100- function ( id , func ) {
100+ function ( id , func ) {
101101 const timeEventName = pluginName + "/" + type + "/" + method ;
102102 const wrappedFunc = genWrappedFunc ( {
103103 func,
@@ -115,12 +115,12 @@ const wrapHooks = (orig, pluginName, smp, type) => {
115115 const hooks = orig . hooks ;
116116 if ( ! hooks ) return hooks ;
117117 const prevWrapped = wrappedHooks . find (
118- w =>
118+ ( w ) =>
119119 w . pluginName === pluginName && ( w . orig === hooks || w . wrapped === hooks )
120120 ) ;
121121 if ( prevWrapped ) return prevWrapped . wrapped ;
122122
123- const genProxy = method => {
123+ const genProxy = ( method ) => {
124124 const proxy = new Proxy ( hooks [ method ] , {
125125 get : ( target , property ) => {
126126 const raw = Reflect . get ( target , property ) ;
@@ -149,6 +149,15 @@ const wrapHooks = (orig, pluginName, smp, type) => {
149149 } ;
150150
151151 const wrapped = Object . keys ( hooks ) . reduce ( ( acc , method ) => {
152+ if ( method === "normalModuleLoader" ) {
153+ Object . defineProperty ( acc , method , {
154+ configurable : true ,
155+ enumerable : true ,
156+ get : ( ) => genProxy ( method ) ,
157+ } ) ;
158+ return acc ;
159+ }
160+
152161 acc [ method ] = genProxy ( method ) ;
153162 return acc ;
154163 } , { } ) ;
@@ -170,7 +179,8 @@ const construcNamesToWrap = [
170179const wrappedObjs = [ ] ;
171180const findWrappedObj = ( orig , pluginName ) => {
172181 const prevWrapped = wrappedObjs . find (
173- w => w . pluginName === pluginName && ( w . orig === orig || w . wrapped === orig )
182+ ( w ) =>
183+ w . pluginName === pluginName && ( w . orig === orig || w . wrapped === orig )
174184 ) ;
175185 if ( prevWrapped ) return prevWrapped . wrapped ;
176186} ;
@@ -179,15 +189,15 @@ const wrap = (orig, pluginName, smp, addEndEvent) => {
179189 const prevWrapped = findWrappedObj ( orig , pluginName ) ;
180190 if ( prevWrapped ) return prevWrapped ;
181191
182- const getOrigConstrucName = target =>
192+ const getOrigConstrucName = ( target ) =>
183193 target && target . constructor && target . constructor . name ;
184- const getShouldWrap = target => {
194+ const getShouldWrap = ( target ) => {
185195 const origConstrucName = getOrigConstrucName ( target ) ;
186196 return construcNamesToWrap . includes ( origConstrucName ) ;
187197 } ;
188198 const shouldWrap = getShouldWrap ( orig ) ;
189199 const shouldSoftWrap = Object . keys ( orig )
190- . map ( k => orig [ k ] )
200+ . map ( ( k ) => orig [ k ] )
191201 . some ( getShouldWrap ) ;
192202
193203 let wrappedReturn ;
@@ -196,7 +206,7 @@ const wrap = (orig, pluginName, smp, addEndEvent) => {
196206 const vanillaFunc = orig . name === "next" ;
197207 wrappedReturn =
198208 vanillaFunc && addEndEvent
199- ? function ( ) {
209+ ? function ( ) {
200210 // do this before calling the callback, since the callback can start
201211 // the next plugin step
202212 addEndEvent ( ) ;
0 commit comments