Skip to content

Commit 185eb18

Browse files
committedJan 12, 2023
Revert "fix(transformer): don't use cache when tsJestConfig is different (#3966)"
This reverts commit a445638.
1 parent d30d389 commit 185eb18

File tree

2 files changed

+19
-28
lines changed

2 files changed

+19
-28
lines changed
 

‎src/legacy/ts-jest-transformer.spec.ts

-10
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,6 @@ describe('TsJestTransformer', () => {
8080
expect(cs2).toBe(cs1)
8181
})
8282

83-
test('should return different config set for different tsJestConfig', () => {
84-
const obj2 = { ...obj1, config: { ...obj1.config } }
85-
// @ts-expect-error testing purpose
86-
const cs1 = new TsJestTransformer({ isolatedModules: true })._configsFor(obj1)
87-
// @ts-expect-error testing purpose
88-
const cs2 = new TsJestTransformer({ isolatedModules: false })._configsFor(obj2)
89-
90-
expect(cs2).not.toBe(cs1)
91-
})
92-
9383
test(`should not read disk cache with isolatedModules true`, () => {
9484
const tr = new TsJestTransformer()
9585
const cs = createConfigSet({

‎src/legacy/ts-jest-transformer.ts

+19-18
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,8 @@ export class TsJestTransformer implements SyncTransformer {
8686
this._watchMode = ccs.watchMode
8787
configSet = ccs.configSet
8888
} else {
89-
if (config.globals?.['ts-jest']) {
90-
this._logger.warn(Deprecations.GlobalsTsJestConfigOption)
91-
}
92-
const jestGlobalsConfig = config.globals ?? {}
93-
const tsJestGlobalsConfig = jestGlobalsConfig['ts-jest'] ?? {}
94-
const migratedConfig = this.tsJestConfig
95-
? {
96-
...config,
97-
globals: {
98-
...jestGlobalsConfig,
99-
'ts-jest': {
100-
...tsJestGlobalsConfig,
101-
...this.tsJestConfig,
102-
},
103-
},
104-
}
105-
: config
10689
// try to look-it up by stringified version
107-
const serializedJestCfg = stringify(migratedConfig)
90+
const serializedJestCfg = stringify(config)
10891
const serializedCcs = TsJestTransformer._cachedConfigSets.find(
10992
(cs) => cs.jestConfig.serialized === serializedJestCfg,
11093
)
@@ -122,6 +105,24 @@ export class TsJestTransformer implements SyncTransformer {
122105
} else {
123106
// create the new record in the index
124107
this._logger.info('no matching config-set found, creating a new one')
108+
109+
if (config.globals?.['ts-jest']) {
110+
this._logger.warn(Deprecations.GlobalsTsJestConfigOption)
111+
}
112+
const jestGlobalsConfig = config.globals ?? {}
113+
const tsJestGlobalsConfig = jestGlobalsConfig['ts-jest'] ?? {}
114+
const migratedConfig = this.tsJestConfig
115+
? {
116+
...config,
117+
globals: {
118+
...jestGlobalsConfig,
119+
'ts-jest': {
120+
...tsJestGlobalsConfig,
121+
...this.tsJestConfig,
122+
},
123+
},
124+
}
125+
: config
125126
configSet = this._createConfigSet(migratedConfig)
126127
const jest = { ...migratedConfig }
127128
// we need to remove some stuff from jest config

0 commit comments

Comments
 (0)
Please sign in to comment.