@@ -31,11 +31,14 @@ interface TsJestHooksMap {
31
31
afterProcess ?( args : any [ ] , result : string | TransformedSource ) : string | TransformedSource | void
32
32
}
33
33
34
- export interface DepGraphInfo {
34
+ interface DepGraphInfo {
35
35
fileContent : string
36
36
resolveModuleNames : string [ ]
37
37
}
38
38
39
+ /**
40
+ * @internal
41
+ */
39
42
export const CACHE_KEY_EL_SEPARATOR = '\x00'
40
43
41
44
export class TsJestTransformer implements Transformer {
@@ -45,11 +48,11 @@ export class TsJestTransformer implements Transformer {
45
48
* @internal
46
49
*/
47
50
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 > ( )
53
56
54
57
constructor ( ) {
55
58
this . _logger = rootLogger . child ( { namespace : 'ts-jest-transformer' } )
@@ -58,7 +61,7 @@ export class TsJestTransformer implements Transformer {
58
61
this . _logger . debug ( 'created new transformer' )
59
62
}
60
63
61
- protected _configsFor ( transformOptions : TransformOptionsTsJest ) : ConfigSet {
64
+ private _configsFor ( transformOptions : TransformOptionsTsJest ) : ConfigSet {
62
65
const { config, cacheFS } = transformOptions
63
66
const ccs : CachedConfigSet | undefined = TsJestTransformer . _cachedConfigSets . find (
64
67
( cs ) => cs . jestConfig . value === config ,
@@ -90,14 +93,14 @@ export class TsJestTransformer implements Transformer {
90
93
// create the new record in the index
91
94
this . _logger . info ( 'no matching config-set found, creating a new one' )
92
95
93
- configSet = new ConfigSet ( config )
96
+ configSet = this . _createConfigSet ( config )
94
97
const jest = { ...config }
95
98
// we need to remove some stuff from jest config
96
99
// this which does not depend on config
97
100
jest . name = undefined as any
98
101
jest . cacheDirectory = undefined as any
99
102
this . _transformCfgStr = `${ new JsonableValue ( jest ) . serialized } ${ configSet . cacheSuffix } `
100
- this . _compiler = new TsJestCompiler ( configSet , cacheFS )
103
+ this . _compiler = this . _createCompiler ( configSet , cacheFS )
101
104
this . _getFsCachedResolvedModules ( configSet )
102
105
TsJestTransformer . _cachedConfigSets . push ( {
103
106
jestConfig : new JsonableValue ( config ) ,
@@ -113,6 +116,16 @@ export class TsJestTransformer implements Transformer {
113
116
return configSet
114
117
}
115
118
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
+
116
129
/**
117
130
* @public
118
131
*/
@@ -260,7 +273,7 @@ export class TsJestTransformer implements Transformer {
260
273
/**
261
274
* Subclasses extends `TsJestTransformer` can call this method to get resolved module disk cache
262
275
*/
263
- protected _getFsCachedResolvedModules ( configSet : ConfigSet ) : void {
276
+ private _getFsCachedResolvedModules ( configSet : ConfigSet ) : void {
264
277
const cacheDir = configSet . tsCacheDir
265
278
if ( ! configSet . isolatedModules && cacheDir ) {
266
279
// Make sure the cache directory exists before continuing.
0 commit comments