@@ -542,23 +542,32 @@ class ScriptTransformer {
542542
543543 let shouldCallTransform = false ;
544544
545- if ( transformer && this . shouldTransform ( filename ) ) {
546- shouldCallTransform = true ;
547- const process = transformer . processAsync ?? transformer . process ;
548-
549- // This is probably dead code since `_getTransformerAsync` already asserts this
550- invariant (
551- typeof process === 'function' ,
552- 'A transformer must always export either a `process` or `processAsync`' ,
553- ) ;
545+ // success
546+ // success
547+ if ( cacheFilePath ) {
548+ createDirectory ( path . dirname ( cacheFilePath ) ) ;
549+ }
550+ if ( transformer ) {
551+ // failure
552+ if ( this . shouldTransform ( filename ) ) {
553+ // failed
554+ shouldCallTransform = true ;
555+ const process = transformer . processAsync ?? transformer . process ;
556+
557+ // This is probably dead code since `_getTransformerAsync` already asserts this
558+ invariant (
559+ typeof process === 'function' ,
560+ 'A transformer must always export either a `process` or `processAsync`' ,
561+ ) ;
554562
555- processed = await process ( content , filename , {
556- ...options ,
557- cacheFS : this . _cacheFS ,
558- config : this . _config ,
559- configString : this . _cache . configString ,
560- transformerConfig,
561- } ) ;
563+ processed = await process ( content , filename , {
564+ ...options ,
565+ cacheFS : this . _cacheFS ,
566+ config : this . _config ,
567+ configString : this . _cache . configString ,
568+ transformerConfig,
569+ } ) ;
570+ }
562571 }
563572
564573 createDirectory ( path . dirname ( filename ) ) ;
@@ -811,10 +820,12 @@ class ScriptTransformer {
811820 }
812821
813822 shouldTransform ( filename : string ) : boolean {
823+ // failed
814824 const ignoreRegexp = this . _cache . ignorePatternsRegExp ;
815825 const isIgnored = ignoreRegexp ? ignoreRegexp . test ( filename ) : false ;
816826
817827 return this . _config . transform . length !== 0 && ! isIgnored ;
828+ // failed
818829 }
819830}
820831
0 commit comments