1- import type { TBabelCore , TBabelJest , TTypeScript , TEsBuild } from '../types'
1+ import type { TBabelCore , TBabelJest , TEsBuild , TTypeScript } from '../types'
22
33import { rootLogger } from './logger'
44import { Memoize } from './memoize'
55import { Errors , Helps , ImportReasons , interpolate } from './messages'
66
7- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8- type ModulePatcher < T = any > = ( module : T ) => T
9-
107const logger = rootLogger . child ( { namespace : 'Importer' } )
118
129// When adding an optional dependency which has another reason, add the reason in ImportReasons, and
@@ -26,14 +23,9 @@ export class Importer {
2623 static get instance ( ) : Importer {
2724 logger . debug ( 'creating Importer singleton' )
2825
29- // here we can define patches to apply to modules.
30- // it could be fixes that are not deployed, or
31- // abstractions so that multiple versions work the same
3226 return new Importer ( )
3327 }
3428
35- constructor ( protected _patches : { [ moduleName : string ] : ModulePatcher [ ] } = { } ) { }
36-
3729 babelJest ( why : ImportReasons ) : TBabelJest {
3830 return this . _import ( why , 'babel-jest' )
3931 }
@@ -66,13 +58,10 @@ export class Importer {
6658 if ( req . exists ) {
6759 // module exists
6860 loaded = req as RequireResult < true >
69- if ( loaded . error ) {
70- // require-ing it failed
71- logger . error ( { requireResult : contextReq } , `failed loading module '${ name } '` , loaded . error . message )
61+ if ( req . error ) {
62+ logger . error ( { requireResult : contextReq } , `failed loading module '${ name } '` , req . error . message )
7263 } else {
73- // it has been loaded, let's patch it
7464 logger . debug ( { requireResult : contextReq } , 'loaded module' , name )
75- loaded . exports = this . _patch ( name , loaded . exports )
7665 }
7766 break
7867 } else {
@@ -99,17 +88,6 @@ export class Importer {
9988 throw result . error
10089 }
10190
102- @Memoize ( ( name ) => name )
103- protected _patch < T > ( name : string , unpatched : T ) : T {
104- if ( name in this . _patches ) {
105- logger . debug ( 'patching' , name )
106-
107- return this . _patches [ name ] . reduce ( ( mod , patcher ) => patcher ( mod ) , unpatched )
108- }
109-
110- return unpatched
111- }
112-
11391 protected _import < T > (
11492 why : string ,
11593 moduleName : string ,
0 commit comments