@@ -542,23 +542,32 @@ class ScriptTransformer {
542
542
543
543
let shouldCallTransform = false ;
544
544
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
+ ) ;
554
562
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
+ }
562
571
}
563
572
564
573
createDirectory ( path . dirname ( filename ) ) ;
@@ -811,10 +820,12 @@ class ScriptTransformer {
811
820
}
812
821
813
822
shouldTransform ( filename : string ) : boolean {
823
+ // failed
814
824
const ignoreRegexp = this . _cache . ignorePatternsRegExp ;
815
825
const isIgnored = ignoreRegexp ? ignoreRegexp . test ( filename ) : false ;
816
826
817
827
return this . _config . transform . length !== 0 && ! isIgnored ;
828
+ // failed
818
829
}
819
830
}
820
831
0 commit comments