@@ -31,11 +31,14 @@ interface TsJestHooksMap {
3131 afterProcess ?( args : any [ ] , result : string | TransformedSource ) : string | TransformedSource | void
3232}
3333
34- export interface DepGraphInfo {
34+ interface DepGraphInfo {
3535 fileContent : string
3636 resolveModuleNames : string [ ]
3737}
3838
39+ /**
40+ * @internal
41+ */
3942export const CACHE_KEY_EL_SEPARATOR = '\x00'
4043
4144export class TsJestTransformer implements Transformer {
@@ -45,11 +48,11 @@ export class TsJestTransformer implements Transformer {
4548 * @internal
4649 */
4750 private static readonly _cachedConfigSets : CachedConfigSet [ ] = [ ]
48- protected _compiler ! : TsJestCompiler
49- protected readonly _logger : Logger
50- protected _tsResolvedModulesCachePath : string | undefined
51- protected _transformCfgStr ! : string
52- protected _depGraphs : Map < string , DepGraphInfo > = new Map < string , DepGraphInfo > ( )
51+ private readonly _logger : Logger
52+ private _compiler ! : TsJestCompiler
53+ private _tsResolvedModulesCachePath : string | undefined
54+ private _transformCfgStr ! : string
55+ private _depGraphs : Map < string , DepGraphInfo > = new Map < string , DepGraphInfo > ( )
5356
5457 constructor ( ) {
5558 this . _logger = rootLogger . child ( { namespace : 'ts-jest-transformer' } )
@@ -58,7 +61,7 @@ export class TsJestTransformer implements Transformer {
5861 this . _logger . debug ( 'created new transformer' )
5962 }
6063
61- protected _configsFor ( transformOptions : TransformOptionsTsJest ) : ConfigSet {
64+ private _configsFor ( transformOptions : TransformOptionsTsJest ) : ConfigSet {
6265 const { config, cacheFS } = transformOptions
6366 const ccs : CachedConfigSet | undefined = TsJestTransformer . _cachedConfigSets . find (
6467 ( cs ) => cs . jestConfig . value === config ,
@@ -90,14 +93,14 @@ export class TsJestTransformer implements Transformer {
9093 // create the new record in the index
9194 this . _logger . info ( 'no matching config-set found, creating a new one' )
9295
93- configSet = new ConfigSet ( config )
96+ configSet = this . _createConfigSet ( config )
9497 const jest = { ...config }
9598 // we need to remove some stuff from jest config
9699 // this which does not depend on config
97100 jest . name = undefined as any
98101 jest . cacheDirectory = undefined as any
99102 this . _transformCfgStr = `${ new JsonableValue ( jest ) . serialized } ${ configSet . cacheSuffix } `
100- this . _compiler = new TsJestCompiler ( configSet , cacheFS )
103+ this . _compiler = this . _createCompiler ( configSet , cacheFS )
101104 this . _getFsCachedResolvedModules ( configSet )
102105 TsJestTransformer . _cachedConfigSets . push ( {
103106 jestConfig : new JsonableValue ( config ) ,
@@ -113,6 +116,16 @@ export class TsJestTransformer implements Transformer {
113116 return configSet
114117 }
115118
119+ // eslint-disable-next-line class-methods-use-this
120+ protected _createConfigSet ( config : ProjectConfigTsJest ) : ConfigSet {
121+ return new ConfigSet ( config )
122+ }
123+
124+ // eslint-disable-next-line class-methods-use-this
125+ protected _createCompiler ( configSet : ConfigSet , cacheFS : Map < string , string > ) : TsJestCompiler {
126+ return new TsJestCompiler ( configSet , cacheFS )
127+ }
128+
116129 /**
117130 * @public
118131 */
@@ -260,7 +273,7 @@ export class TsJestTransformer implements Transformer {
260273 /**
261274 * Subclasses extends `TsJestTransformer` can call this method to get resolved module disk cache
262275 */
263- protected _getFsCachedResolvedModules ( configSet : ConfigSet ) : void {
276+ private _getFsCachedResolvedModules ( configSet : ConfigSet ) : void {
264277 const cacheDir = configSet . tsCacheDir
265278 if ( ! configSet . isolatedModules && cacheDir ) {
266279 // Make sure the cache directory exists before continuing.
0 commit comments