ts-jest 29.2.0 → 29.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.ts-jest-digest CHANGED
@@ -1 +1 @@
1
- 6514d17e165dc726d2f9e97b857c0b01ce3b4200
1
+ f3df8dbe41fa9b05f310848253b7f1d8606c147a
package/CHANGELOG.md CHANGED
@@ -1,4 +1,24 @@
1
- ## 29.2.0 (2024-07-08)
1
+ ### [29.2.2](https://github.com/kulshekhar/ts-jest/compare/v29.2.1...v29.2.2) (2024-07-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fix(compiler): update memory cache after changing `module` value ([94db43f](https://github.com/kulshekhar/ts-jest/commit/94db43f)), closes [#4439](https://github.com/kulshekhar/ts-jest/issues/4439)
7
+
8
+
9
+
10
+ ### [29.2.1](https://github.com/kulshekhar/ts-jest/compare/v29.2.0...v29.2.1) (2024-07-10)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * fix: move `ejs` to `dep` instead of `peerDep` ([26e31a7](https://github.com/kulshekhar/ts-jest/commit/26e31a7))
16
+ * fix: set `allowSyntheticDefaultImports` properly ([ff4b302](https://github.com/kulshekhar/ts-jest/commit/ff4b302)), closes [#4156](https://github.com/kulshekhar/ts-jest/issues/4156)
17
+ * fix(compiler): support `Node16/NodeNext` value for `target` ([2f5cc0c](https://github.com/kulshekhar/ts-jest/commit/2f5cc0c)), closes [#4198](https://github.com/kulshekhar/ts-jest/issues/4198)
18
+
19
+
20
+
21
+ ## [29.2.0](https://github.com/kulshekhar/ts-jest/compare/v29.1.5...v29.2.0) (2024-07-08)
2
22
 
3
23
 
4
24
  ### Bug Fixes
@@ -9,8 +29,8 @@
9
29
  ### Features
10
30
 
11
31
  * feat(cli): allow migrating cjs `presets` to `transform` config ([22fb027](https://github.com/kulshekhar/ts-jest/commit/22fb027))
12
- * feat(presets): add util functions to create ESM presets ([06f78ed](https://github.com/kulshekhar/ts-jest/commit/06f78ed))
13
- * feat(presets): add util functions to create CJS presets ([f9cc3c0](https://github.com/kulshekhar/ts-jest/commit/f9cc3c0))
32
+ * feat(presets): add util functions to create ESM presets ([06f78ed](https://github.com/kulshekhar/ts-jest/commit/06f78ed)), close [#4200](https://github.com/kulshekhar/ts-jest/issues/4200)
33
+ * feat(presets): add util functions to create CJS presets ([f9cc3c0](https://github.com/kulshekhar/ts-jest/commit/f9cc3c0)), close [#4200](https://github.com/kulshekhar/ts-jest/issues/4200)
14
34
 
15
35
 
16
36
  ### Code refactoring
@@ -29,7 +49,7 @@
29
49
 
30
50
 
31
51
 
32
- ## [29.1.5](https://github.com/kulshekhar/ts-jest/compare/v29.1.4...v29.1.5) (2024-06-16)
52
+ ### [29.1.5](https://github.com/kulshekhar/ts-jest/compare/v29.1.4...v29.1.5) (2024-06-16)
33
53
 
34
54
 
35
55
  ### Bug Fixes
@@ -38,7 +58,7 @@
38
58
 
39
59
 
40
60
 
41
- ## [29.1.4](https://github.com/kulshekhar/ts-jest/compare/v29.1.3...v29.1.4) (2024-05-28)
61
+ ### [29.1.4](https://github.com/kulshekhar/ts-jest/compare/v29.1.3...v29.1.4) (2024-05-28)
42
62
 
43
63
 
44
64
  ### Bug Fixes
@@ -52,7 +72,7 @@
52
72
 
53
73
 
54
74
 
55
- ## [29.1.3](https://github.com/kulshekhar/ts-jest/compare/v29.1.2...v29.1.3) (2024-05-21)
75
+ ### [29.1.3](https://github.com/kulshekhar/ts-jest/compare/v29.1.2...v29.1.3) (2024-05-21)
56
76
 
57
77
 
58
78
  ### Bug Fixes
@@ -67,7 +87,7 @@
67
87
 
68
88
 
69
89
 
70
- ## [29.1.2](https://github.com/kulshekhar/ts-jest/compare/v29.1.1...v29.1.2) (2024-01-22)
90
+ ### [29.1.2](https://github.com/kulshekhar/ts-jest/compare/v29.1.1...v29.1.2) (2024-01-22)
71
91
 
72
92
 
73
93
  ### Bug Fixes
@@ -87,7 +107,7 @@
87
107
 
88
108
 
89
109
 
90
- # [29.1.0](https://github.com/kulshekhar/ts-jest/compare/v29.0.5...v29.1.0) (2023-03-26)
110
+ ## [29.1.0](https://github.com/kulshekhar/ts-jest/compare/v29.0.5...v29.1.0) (2023-03-26)
91
111
 
92
112
 
93
113
  ### Features
@@ -96,7 +116,7 @@
96
116
 
97
117
 
98
118
 
99
- ## [29.0.5](https://github.com/kulshekhar/ts-jest/compare/v29.0.4...v29.0.5) (2023-01-13)
119
+ ### [29.0.5](https://github.com/kulshekhar/ts-jest/compare/v29.0.4...v29.0.5) (2023-01-13)
100
120
 
101
121
 
102
122
  ### Reverts
@@ -105,7 +125,7 @@
105
125
 
106
126
 
107
127
 
108
- ## [29.0.4](https://github.com/kulshekhar/ts-jest/compare/v29.0.3...v29.0.4) (2023-01-10)
128
+ ### [29.0.4](https://github.com/kulshekhar/ts-jest/compare/v29.0.3...v29.0.4) (2023-01-10)
109
129
 
110
130
 
111
131
  ### Bug Fixes
@@ -115,7 +135,7 @@
115
135
 
116
136
 
117
137
 
118
- ## [29.0.3](https://github.com/kulshekhar/ts-jest/compare/v29.0.2...v29.0.3) (2022-09-28)
138
+ ### [29.0.3](https://github.com/kulshekhar/ts-jest/compare/v29.0.2...v29.0.3) (2022-09-28)
119
139
 
120
140
 
121
141
  ### Bug Fixes
@@ -130,7 +150,7 @@
130
150
 
131
151
 
132
152
 
133
- ## [29.0.2](https://github.com/kulshekhar/ts-jest/compare/v29.0.1...v29.0.2) (2022-09-23)
153
+ ### [29.0.2](https://github.com/kulshekhar/ts-jest/compare/v29.0.1...v29.0.2) (2022-09-23)
134
154
 
135
155
 
136
156
  ### Bug Fixes
@@ -140,16 +160,7 @@
140
160
 
141
161
 
142
162
 
143
- ## [29.0.2](https://github.com/kulshekhar/ts-jest/compare/v29.0.1...v29.0.2) (2022-09-22)
144
-
145
-
146
- ### Bug Fixes
147
-
148
- * mark `ts-jest` as optional in `ConfigGlobals` ([#3816](https://github.com/kulshekhar/ts-jest/issues/3816)) ([cbb88bb](https://github.com/kulshekhar/ts-jest/commit/cbb88bba34dbb852d8f4013be6e020769feb306d)), closes [#3815](https://github.com/kulshekhar/ts-jest/issues/3815)
149
-
150
-
151
-
152
- ## [29.0.1](https://github.com/kulshekhar/ts-jest/compare/v29.0.0...v29.0.1) (2022-09-13)
163
+ ### [29.0.1](https://github.com/kulshekhar/ts-jest/compare/v29.0.0...v29.0.1) (2022-09-13)
153
164
 
154
165
 
155
166
  ### Bug Fixes
@@ -21,6 +21,7 @@ export declare class TsCompiler implements TsCompilerInstance {
21
21
  program: Program | undefined;
22
22
  constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
23
23
  getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
24
+ private fixupCompilerOptionsForModuleKind;
24
25
  getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput;
25
26
  protected _transpileOutput(fileContent: string, fileName: string): TranspileOutput;
26
27
  protected _makeTransformers(customTransformers: TsJestAstTransformer): CustomTransformers;
@@ -112,29 +112,31 @@ var TsCompiler = /** @class */ (function () {
112
112
  });
113
113
  return importedModulePaths;
114
114
  };
115
+ TsCompiler.prototype.fixupCompilerOptionsForModuleKind = function (compilerOptions, isEsm) {
116
+ var _a, _b;
117
+ if (!isEsm) {
118
+ var moduleKind_1 = (_a = compilerOptions.module) !== null && _a !== void 0 ? _a : this._ts.ModuleKind.CommonJS;
119
+ var moduleKindValue = [
120
+ this._ts.ModuleKind.CommonJS,
121
+ this._ts.ModuleKind.Node16,
122
+ this._ts.ModuleKind.NodeNext,
123
+ ].includes(moduleKind_1)
124
+ ? moduleKind_1
125
+ : this._ts.ModuleKind.CommonJS;
126
+ return __assign(__assign({}, compilerOptions), { module: moduleKindValue });
127
+ }
128
+ var moduleKind = (_b = compilerOptions.module) !== null && _b !== void 0 ? _b : this._ts.ModuleKind.ESNext;
129
+ var esModuleInterop = [this._ts.ModuleKind.Node16, this._ts.ModuleKind.NodeNext].includes(moduleKind)
130
+ ? true
131
+ : compilerOptions.esModuleInterop;
132
+ return __assign(__assign({}, compilerOptions), { module: moduleKind, esModuleInterop: esModuleInterop !== null && esModuleInterop !== void 0 ? esModuleInterop : false });
133
+ };
115
134
  TsCompiler.prototype.getCompiledOutput = function (fileContent, fileName, options) {
116
135
  var e_1, _a;
136
+ var isEsmMode = this.configSet.useESM && options.supportsStaticESM;
137
+ this._compilerOptions = this.fixupCompilerOptionsForModuleKind(this._initialCompilerOptions, isEsmMode);
117
138
  var moduleKind = this._initialCompilerOptions.module;
118
- var esModuleInterop = this._initialCompilerOptions.esModuleInterop;
119
- var allowSyntheticDefaultImports = this._initialCompilerOptions.allowSyntheticDefaultImports;
120
139
  var currentModuleKind = this._compilerOptions.module;
121
- var isEsmMode = this.configSet.useESM && options.supportsStaticESM;
122
- if ((this.configSet.babelJestTransformer || (!this.configSet.babelJestTransformer && options.supportsStaticESM)) &&
123
- this.configSet.useESM) {
124
- moduleKind =
125
- !moduleKind ||
126
- (moduleKind &&
127
- ![this._ts.ModuleKind.ES2015, this._ts.ModuleKind.ES2020, this._ts.ModuleKind.ESNext].includes(moduleKind))
128
- ? this._ts.ModuleKind.ESNext
129
- : moduleKind;
130
- // Make sure `esModuleInterop` and `allowSyntheticDefaultImports` true to support import CJS into ESM
131
- esModuleInterop = true;
132
- allowSyntheticDefaultImports = true;
133
- }
134
- else {
135
- moduleKind = this._ts.ModuleKind.CommonJS;
136
- }
137
- this._compilerOptions = __assign(__assign({}, this._compilerOptions), { allowSyntheticDefaultImports: allowSyntheticDefaultImports, esModuleInterop: esModuleInterop, module: moduleKind });
138
140
  if (this._languageService) {
139
141
  this._logger.debug({ fileName: fileName }, 'getCompiledOutput(): compiling using language service');
140
142
  // Must set memory cache before attempting to compile
@@ -435,11 +435,6 @@ var ConfigSet = /** @class */ (function () {
435
435
  start: undefined,
436
436
  length: undefined,
437
437
  });
438
- // at least enable synthetic default imports (except if it's set in the input config)
439
- /* istanbul ignore next (already covered in unit test) */
440
- if (!('allowSyntheticDefaultImports' in finalOptions)) {
441
- finalOptions.allowSyntheticDefaultImports = true;
442
- }
443
438
  }
444
439
  // Make sure when allowJs is enabled, outDir is required to have when using allowJs: true
445
440
  if (finalOptions.allowJs && !finalOptions.outDir) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-jest",
3
- "version": "29.2.0",
3
+ "version": "29.2.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": {
@@ -52,6 +52,7 @@
52
52
  "homepage": "https://kulshekhar.github.io/ts-jest",
53
53
  "dependencies": {
54
54
  "bs-logger": "0.x",
55
+ "ejs": "^3.0.0",
55
56
  "fast-json-stable-stringify": "2.x",
56
57
  "jest-util": "^29.0.0",
57
58
  "json5": "^2.2.3",
@@ -111,18 +112,17 @@
111
112
  "@types/semver": "latest",
112
113
  "@types/yargs": "latest",
113
114
  "@types/yargs-parser": "21.0.3",
114
- "@typescript-eslint/eslint-plugin": "^7.15.0",
115
- "@typescript-eslint/parser": "^7.15.0",
115
+ "@typescript-eslint/eslint-plugin": "^7.16.0",
116
+ "@typescript-eslint/parser": "^7.16.0",
116
117
  "babel-jest": "^29.7.0",
117
118
  "conventional-changelog-cli": "^5.0.0",
118
119
  "cross-spawn": "latest",
119
- "ejs": "^3.1.10",
120
120
  "esbuild": "~0.21.5",
121
121
  "eslint": "^8.57.0",
122
122
  "eslint-config-prettier": "^9.1.0",
123
123
  "eslint-plugin-import": "^2.29.1",
124
124
  "eslint-plugin-jest": "^28.6.0",
125
- "eslint-plugin-jsdoc": "^48.5.2",
125
+ "eslint-plugin-jsdoc": "^48.6.0",
126
126
  "eslint-plugin-prefer-arrow": "^1.2.3",
127
127
  "eslint-plugin-prettier": "^4.2.1",
128
128
  "execa": "5.1.1",