@@ -542,23 +542,31 @@ 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 ( transformer ) {
548
+ if ( cacheFilePath ) {
549
+ createDirectory ( path . dirname ( cacheFilePath ) ) ;
550
+ }
551
+ if ( this . shouldTransform ( filename , cacheFilePath ) ) {
552
+ // failed
553
+ shouldCallTransform = true ;
554
+ const process = transformer . processAsync ?? transformer . process ;
555
+
556
+ // This is probably dead code since `_getTransformerAsync` already asserts this
557
+ invariant (
558
+ typeof process === 'function' ,
559
+ 'A transformer must always export either a `process` or `processAsync`' ,
560
+ ) ;
554
561
555
- processed = await process ( content , filename , {
556
- ...options ,
557
- cacheFS : this . _cacheFS ,
558
- config : this . _config ,
559
- configString : this . _cache . configString ,
560
- transformerConfig,
561
- } ) ;
562
+ processed = await process ( content , filename , {
563
+ ...options ,
564
+ cacheFS : this . _cacheFS ,
565
+ config : this . _config ,
566
+ configString : this . _cache . configString ,
567
+ transformerConfig,
568
+ } ) ;
569
+ }
562
570
}
563
571
564
572
createDirectory ( path . dirname ( filename ) ) ;
@@ -810,11 +818,13 @@ class ScriptTransformer {
810
818
}
811
819
}
812
820
813
- shouldTransform ( filename : string ) : boolean {
821
+ shouldTransform ( filename : string , cacheFilePath ?: string ) : boolean {
822
+ // failed
814
823
const ignoreRegexp = this . _cache . ignorePatternsRegExp ;
815
824
const isIgnored = ignoreRegexp ? ignoreRegexp . test ( filename ) : false ;
816
825
817
826
return this . _config . transform . length !== 0 && ! isIgnored ;
827
+ // failed
818
828
}
819
829
}
820
830
0 commit comments