From c88322b7b0387ab301173799cd9a4596d635cec8 Mon Sep 17 00:00:00 2001 From: "anh.pham" Date: Wed, 28 Sep 2022 18:44:34 +0200 Subject: [PATCH 1/2] chore(release): 29.0.3 --- CHANGELOG.md | 15 +++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 284066a0ce..dec1cced59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +## [29.0.3](https://github.com/kulshekhar/ts-jest/compare/v29.0.2...v29.0.3) (2022-09-28) + + +### Bug Fixes + +* merge config from `globals` with transformer config correctly ([#3842](https://github.com/kulshekhar/ts-jest/issues/3842)) ([9c9fd60](https://github.com/kulshekhar/ts-jest/commit/9c9fd6097aea36a6e8b06b0e8841df22896f9121)), closes [#3841](https://github.com/kulshekhar/ts-jest/issues/3841) +* **presets:** allow merging transform config when using presets ([#3833](https://github.com/kulshekhar/ts-jest/issues/3833)) ([afc6a94](https://github.com/kulshekhar/ts-jest/commit/afc6a948b17c2dc22be51b1a9475a0f6ecbbc372)) + + +### Features + +* add `useESM` option to `pathsToModuleNameMapper` options ([#3792](https://github.com/kulshekhar/ts-jest/issues/3792)) ([eabe906](https://github.com/kulshekhar/ts-jest/commit/eabe906e1dd6b132a7b0d05ffc13172cd8a6b73b)) + + + ## [29.0.2](https://github.com/kulshekhar/ts-jest/compare/v29.0.1...v29.0.2) (2022-09-23) diff --git a/package-lock.json b/package-lock.json index cfe76f3217..66ed53d756 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ts-jest", - "version": "29.0.2", + "version": "29.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ts-jest", - "version": "29.0.2", + "version": "29.0.3", "license": "MIT", "dependencies": { "bs-logger": "0.x", diff --git a/package.json b/package.json index fa3d89a01d..a9bbd05754 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-jest", - "version": "29.0.2", + "version": "29.0.3", "main": "dist/index.js", "types": "dist/index.d.ts", "bin": { From 185eb189d7076c717a107066817d2d6959a8fe39 Mon Sep 17 00:00:00 2001 From: ahnpnl <27772165+ahnpnl@users.noreply.github.com> Date: Thu, 12 Jan 2023 22:22:11 +0100 Subject: [PATCH 2/2] Revert "fix(transformer): don't use cache when `tsJestConfig` is different (#3966)" This reverts commit a445638ca631911e8ab1a896ffdfcd21506ce71a. --- src/legacy/ts-jest-transformer.spec.ts | 10 ------- src/legacy/ts-jest-transformer.ts | 37 +++++++++++++------------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/legacy/ts-jest-transformer.spec.ts b/src/legacy/ts-jest-transformer.spec.ts index 708de3d08a..849e2d3041 100644 --- a/src/legacy/ts-jest-transformer.spec.ts +++ b/src/legacy/ts-jest-transformer.spec.ts @@ -80,16 +80,6 @@ describe('TsJestTransformer', () => { expect(cs2).toBe(cs1) }) - test('should return different config set for different tsJestConfig', () => { - const obj2 = { ...obj1, config: { ...obj1.config } } - // @ts-expect-error testing purpose - const cs1 = new TsJestTransformer({ isolatedModules: true })._configsFor(obj1) - // @ts-expect-error testing purpose - const cs2 = new TsJestTransformer({ isolatedModules: false })._configsFor(obj2) - - expect(cs2).not.toBe(cs1) - }) - test(`should not read disk cache with isolatedModules true`, () => { const tr = new TsJestTransformer() const cs = createConfigSet({ diff --git a/src/legacy/ts-jest-transformer.ts b/src/legacy/ts-jest-transformer.ts index 022166a28d..b4dbdc2a20 100644 --- a/src/legacy/ts-jest-transformer.ts +++ b/src/legacy/ts-jest-transformer.ts @@ -86,25 +86,8 @@ export class TsJestTransformer implements SyncTransformer { this._watchMode = ccs.watchMode configSet = ccs.configSet } else { - if (config.globals?.['ts-jest']) { - this._logger.warn(Deprecations.GlobalsTsJestConfigOption) - } - const jestGlobalsConfig = config.globals ?? {} - const tsJestGlobalsConfig = jestGlobalsConfig['ts-jest'] ?? {} - const migratedConfig = this.tsJestConfig - ? { - ...config, - globals: { - ...jestGlobalsConfig, - 'ts-jest': { - ...tsJestGlobalsConfig, - ...this.tsJestConfig, - }, - }, - } - : config // try to look-it up by stringified version - const serializedJestCfg = stringify(migratedConfig) + const serializedJestCfg = stringify(config) const serializedCcs = TsJestTransformer._cachedConfigSets.find( (cs) => cs.jestConfig.serialized === serializedJestCfg, ) @@ -122,6 +105,24 @@ export class TsJestTransformer implements SyncTransformer { } else { // create the new record in the index this._logger.info('no matching config-set found, creating a new one') + + if (config.globals?.['ts-jest']) { + this._logger.warn(Deprecations.GlobalsTsJestConfigOption) + } + const jestGlobalsConfig = config.globals ?? {} + const tsJestGlobalsConfig = jestGlobalsConfig['ts-jest'] ?? {} + const migratedConfig = this.tsJestConfig + ? { + ...config, + globals: { + ...jestGlobalsConfig, + 'ts-jest': { + ...tsJestGlobalsConfig, + ...this.tsJestConfig, + }, + }, + } + : config configSet = this._createConfigSet(migratedConfig) const jest = { ...migratedConfig } // we need to remove some stuff from jest config