ts-jest 29.4.9 → 29.4.11

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
- 58edfe49f3f9192570efa8fa26d9cbc324d1324e
1
+ 73233cd15fa36234d30a07a1efa9643162305524
package/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
1
+ ## [29.4.11](https://github.com/kulshekhar/ts-jest/compare/v29.4.10...v29.4.11) (2026-05-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * preserve Bundler on the CJS path under TypeScript >= 6 ([3941818](https://github.com/kulshekhar/ts-jest/commit/39418187515f11b6584d35a4e3ddf50231f74936)), closes [#4198](https://github.com/kulshekhar/ts-jest/issues/4198)
7
+
8
+
9
+
10
+ ## [29.4.10](https://github.com/kulshekhar/ts-jest/compare/v29.4.9...v29.4.10) (2026-05-18)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * pass `resolutionMode` to `ts.resolveModuleName` for hybrid module support ([b557a85](https://github.com/kulshekhar/ts-jest/commit/b557a85f85c3fd34523ec3a15293afbdc9dea83c))
16
+ * rebuild `Program` when consecutive compiles need different module kinds ([a82a2b3](https://github.com/kulshekhar/ts-jest/commit/a82a2b32c4987a5249fd5284283117dd2fa3be47)), closes [#4774](https://github.com/kulshekhar/ts-jest/issues/4774)
17
+ * respect tsconfig `moduleResolution` instead of forcing `Node10` ([1bffffc](https://github.com/kulshekhar/ts-jest/commit/1bffffc667557c173ae0c1f93dd436920775dac4))
18
+ * **transformer:** transpile `mjs` files from `node_modules` for CJS mode ([96d025d](https://github.com/kulshekhar/ts-jest/commit/96d025dd912ea2bceb18b67d2d509ada7a756d9d))
19
+ * **transformer:** use a consistent comparator in hoist-jest sortStatements ([8a8fd2f](https://github.com/kulshekhar/ts-jest/commit/8a8fd2fb8446655bba18367db9306a1089490e62))
20
+
21
+
22
+
23
+ ## [29.4.9](https://github.com/kulshekhar/ts-jest/compare/v29.4.8...v29.4.9) (2026-04-01)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * use correct registry for npm OIDC trusted publishing ([f8a9cc9](https://github.com/kulshekhar/ts-jest/commit/f8a9cc9892))
29
+
30
+
31
+
32
+ ## [29.4.8](https://github.com/kulshekhar/ts-jest/compare/v29.4.7...v29.4.8) (2026-04-01)
33
+
34
+
35
+ ### Bug Fixes
36
+
37
+ * wrong published assets
38
+
39
+
40
+
1
41
  ## [29.4.7](https://github.com/kulshekhar/ts-jest/compare/v29.4.6...v29.4.7) (2026-04-01)
2
42
 
3
43
 
@@ -5,6 +45,8 @@
5
45
 
6
46
  * support TypeScript v6 ([eda517d](https://github.com/kulshekhar/ts-jest/commit/eda517d226389317d99572887d3c1aa93c81be87))
7
47
 
48
+
49
+
8
50
  ## [29.4.6](https://github.com/kulshekhar/ts-jest/compare/v29.4.5...v29.4.6) (2025-12-01)
9
51
 
10
52
 
@@ -20,7 +20,108 @@ export declare class TsCompiler implements TsCompilerInstance {
20
20
  program: Program | undefined;
21
21
  constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
22
22
  getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
23
+ /**
24
+ * Apply ts-jest's runtime fixups on top of the user's compiler options before
25
+ * handing them to the language service or transpiler.
26
+ *
27
+ * Two compiler-options now flow through dedicated helpers so the produced
28
+ * options are always a TypeScript-valid combination:
29
+ *
30
+ * - `moduleResolution` is delegated to `resolveCompatibleModuleResolution`,
31
+ * which preserves the user's value when it is valid alongside the
32
+ * `module` ts-jest forces at runtime (CommonJS on the CJS path, or
33
+ * ESNext / the user's original `module` on the ESM path) and otherwise
34
+ * substitutes a TypeScript-valid alternative. When the user has not set
35
+ * a value the historical Node10 default is kept, so unchanged tsconfigs
36
+ * see the exact same resolved options as before.
37
+ *
38
+ * - `customConditions` is delegated to `preserveCustomConditionsIfCompatible`,
39
+ * which keeps the user's value only when the resolved
40
+ * `moduleResolution` supports it (`Bundler` / `Node16` / `NodeNext`)
41
+ * and clears it otherwise. The pre-#4198 code unconditionally cleared
42
+ * this option because the hardcoded `Node10` override always made it
43
+ * incompatible; that is no longer true.
44
+ *
45
+ * @see https://github.com/kulshekhar/ts-jest/issues/4198
46
+ */
23
47
  private fixupCompilerOptionsForModuleKind;
48
+ /**
49
+ * Pick a `moduleResolution` value that is valid alongside the `module` ts-jest
50
+ * forces at runtime. Closes #4198: previously this was hardcoded to Node10 and
51
+ * silently overrode whatever the user set in tsconfig, even when the user value
52
+ * would have been valid (e.g. Bundler with module: ESNext, Classic with CommonJS).
53
+ *
54
+ * Substitution rules — each tied to a specific TypeScript diagnostic that the
55
+ * resulting combination would otherwise raise. The "Bundler-compatible" set is
56
+ * the one defined by `isBundlerCompatibleModuleKind` (ES2015 / ES2020 / ES2022
57
+ * / ESNext / Preserve); everything else (CommonJS / AMD / UMD / System / None)
58
+ * is treated as Bundler-incompatible across the full supported TS range.
59
+ *
60
+ * - Node16 / NodeNext require `module: Node16` or `module: NodeNext` (TS5110).
61
+ * ts-jest never emits those module kinds, so these user-supplied values are
62
+ * substituted: to Bundler when the forced module is in the
63
+ * Bundler-compatible set, or to Node10 otherwise. (Pairing Bundler with a
64
+ * non-ES module raises TS5095, and Node10 is the only kind that has been
65
+ * valid with non-ES modules across every TypeScript version ts-jest
66
+ * supports.)
67
+ *
68
+ * - User-supplied Bundler with a non-Bundler-compatible forced module is
69
+ * TS5095, substitute Node10. (TypeScript 6 relaxed this for
70
+ * `module: CommonJS` specifically; that relaxation is encoded inside
71
+ * `isBundlerCompatibleModuleKind` via a runtime version check, so on
72
+ * TS ≥ 6 user-supplied Bundler passes through unchanged on the CJS
73
+ * path.)
74
+ *
75
+ * - Anything else (Node10 / Classic / unset) passes through or falls back
76
+ * to Node10. These pairings are valid with every forced module kind.
77
+ *
78
+ * Compatibility: `ModuleResolutionKind.Bundler` was introduced in
79
+ * TypeScript 5.0. ts-jest declares `peerDependencies: { typescript: ">=4.3 <7" }`,
80
+ * so the Bundler member is `undefined` at runtime on TypeScript 4.3 - 4.9.
81
+ * The Node16/NodeNext substitution falls back to Node10 in that case
82
+ * (`bundlerResolution` below) to keep the function deterministic across the
83
+ * full supported range. Users on TypeScript < 5 can never have set Bundler in
84
+ * tsconfig (the parser rejects it), so the user-supplied-Bundler branch is
85
+ * unreachable there and needs no separate guard.
86
+ */
87
+ private resolveCompatibleModuleResolution;
88
+ /**
89
+ * TypeScript pairs `moduleResolution: bundler` only with ES-module module
90
+ * kinds (`ES2015` / `ES2020` / `ES2022` / `ESNext`) or `Preserve` (added in
91
+ * TypeScript 5.4). Pairing `bundler` with `CommonJS`, `AMD`, `UMD`, `System`,
92
+ * or `None` raises TS5095. Used by `resolveCompatibleModuleResolution` to
93
+ * gate the `Node16` / `NodeNext` → `Bundler` substitution and the
94
+ * user-supplied-`Bundler` pass-through, so neither path emits an invalid
95
+ * pair when the user has selected a non-ES `module`.
96
+ *
97
+ * TypeScript 6.0 relaxed TS5095 for `module: CommonJS` specifically
98
+ * (`CommonJS` + `Bundler` is a valid pair on TS ≥ 6); the other non-ES
99
+ * module kinds (`AMD` / `UMD` / `System` / `None`) remain Bundler-incompatible
100
+ * on every TypeScript version. The version is detected at runtime from
101
+ * `this._ts.version` so the function stays correct across the full
102
+ * peerDependency range (`>=4.3 <7`).
103
+ *
104
+ * @see https://www.typescriptlang.org/tsconfig/#moduleResolution
105
+ */
106
+ private isBundlerCompatibleModuleKind;
107
+ /**
108
+ * Pass `customConditions` through unchanged when the resolved
109
+ * `moduleResolution` is one of the kinds that supports it (`Bundler`,
110
+ * `Node16`, `NodeNext`); strip it otherwise. TypeScript raises TS5098
111
+ * when `customConditions` is paired with any other resolution kind
112
+ * (verified empirically against TypeScript 5.9.3 with `tsc -p`).
113
+ *
114
+ * Before #4198 the surrounding `fixupCompilerOptionsForModuleKind`
115
+ * unconditionally cleared `customConditions` because the hardcoded
116
+ * `Node10` override always made it incompatible. After #4198 the
117
+ * resolved `moduleResolution` can be `Bundler` (e.g. when the user
118
+ * has `Node16`/`NodeNext` paired with an ES-family `module`), so we
119
+ * need to preserve the user's `customConditions` in that case rather
120
+ * than silently dropping it.
121
+ *
122
+ * @see https://www.typescriptlang.org/tsconfig/#customConditions
123
+ */
124
+ private preserveCustomConditionsIfCompatible;
24
125
  getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput;
25
126
  protected _transpileOutput(fileContent: string, fileName: string): TranspileOutput;
26
127
  protected _makeTransformers(customTransformers: TsJestAstTransformer): CustomTransformers;
@@ -49,6 +49,10 @@ class TsCompiler {
49
49
  * @internal
50
50
  */
51
51
  _projectVersion = 1;
52
+ /**
53
+ * @internal
54
+ */
55
+ _previousCompiledModuleKind;
52
56
  /**
53
57
  * @internal
54
58
  */
@@ -107,17 +111,38 @@ class TsCompiler {
107
111
  });
108
112
  return importedModulePaths;
109
113
  }
114
+ /**
115
+ * Apply ts-jest's runtime fixups on top of the user's compiler options before
116
+ * handing them to the language service or transpiler.
117
+ *
118
+ * Two compiler-options now flow through dedicated helpers so the produced
119
+ * options are always a TypeScript-valid combination:
120
+ *
121
+ * - `moduleResolution` is delegated to `resolveCompatibleModuleResolution`,
122
+ * which preserves the user's value when it is valid alongside the
123
+ * `module` ts-jest forces at runtime (CommonJS on the CJS path, or
124
+ * ESNext / the user's original `module` on the ESM path) and otherwise
125
+ * substitutes a TypeScript-valid alternative. When the user has not set
126
+ * a value the historical Node10 default is kept, so unchanged tsconfigs
127
+ * see the exact same resolved options as before.
128
+ *
129
+ * - `customConditions` is delegated to `preserveCustomConditionsIfCompatible`,
130
+ * which keeps the user's value only when the resolved
131
+ * `moduleResolution` supports it (`Bundler` / `Node16` / `NodeNext`)
132
+ * and clears it otherwise. The pre-#4198 code unconditionally cleared
133
+ * this option because the hardcoded `Node10` override always made it
134
+ * incompatible; that is no longer true.
135
+ *
136
+ * @see https://github.com/kulshekhar/ts-jest/issues/4198
137
+ */
110
138
  fixupCompilerOptionsForModuleKind(compilerOptions, isEsm) {
111
- const moduleResolution = this._ts.ModuleResolutionKind.Node10 ?? this._ts.ModuleResolutionKind.NodeJs;
112
139
  if (!isEsm) {
140
+ const moduleResolution = this.resolveCompatibleModuleResolution(this._ts.ModuleKind.CommonJS, compilerOptions.moduleResolution);
113
141
  return {
114
142
  ...compilerOptions,
115
143
  module: this._ts.ModuleKind.CommonJS,
116
144
  moduleResolution,
117
- /**
118
- * This option is only supported in `Node16`/`NodeNext` and `Bundler` module, see https://www.typescriptlang.org/tsconfig/#customConditions
119
- */
120
- customConditions: undefined,
145
+ customConditions: this.preserveCustomConditionsIfCompatible(moduleResolution, compilerOptions.customConditions),
121
146
  };
122
147
  }
123
148
  let moduleKind = compilerOptions.module ?? this._ts.ModuleKind.ESNext;
@@ -126,22 +151,138 @@ class TsCompiler {
126
151
  esModuleInterop = true;
127
152
  moduleKind = this._ts.ModuleKind.ESNext;
128
153
  }
154
+ const moduleResolution = this.resolveCompatibleModuleResolution(moduleKind, compilerOptions.moduleResolution);
129
155
  return {
130
156
  ...compilerOptions,
131
157
  module: moduleKind,
132
158
  esModuleInterop,
133
159
  moduleResolution,
134
- /**
135
- * This option is only supported in `Node16`/`NodeNext` and `Bundler` module, see https://www.typescriptlang.org/tsconfig/#customConditions
136
- */
137
- customConditions: undefined,
160
+ customConditions: this.preserveCustomConditionsIfCompatible(moduleResolution, compilerOptions.customConditions),
138
161
  };
139
162
  }
163
+ /**
164
+ * Pick a `moduleResolution` value that is valid alongside the `module` ts-jest
165
+ * forces at runtime. Closes #4198: previously this was hardcoded to Node10 and
166
+ * silently overrode whatever the user set in tsconfig, even when the user value
167
+ * would have been valid (e.g. Bundler with module: ESNext, Classic with CommonJS).
168
+ *
169
+ * Substitution rules — each tied to a specific TypeScript diagnostic that the
170
+ * resulting combination would otherwise raise. The "Bundler-compatible" set is
171
+ * the one defined by `isBundlerCompatibleModuleKind` (ES2015 / ES2020 / ES2022
172
+ * / ESNext / Preserve); everything else (CommonJS / AMD / UMD / System / None)
173
+ * is treated as Bundler-incompatible across the full supported TS range.
174
+ *
175
+ * - Node16 / NodeNext require `module: Node16` or `module: NodeNext` (TS5110).
176
+ * ts-jest never emits those module kinds, so these user-supplied values are
177
+ * substituted: to Bundler when the forced module is in the
178
+ * Bundler-compatible set, or to Node10 otherwise. (Pairing Bundler with a
179
+ * non-ES module raises TS5095, and Node10 is the only kind that has been
180
+ * valid with non-ES modules across every TypeScript version ts-jest
181
+ * supports.)
182
+ *
183
+ * - User-supplied Bundler with a non-Bundler-compatible forced module is
184
+ * TS5095, substitute Node10. (TypeScript 6 relaxed this for
185
+ * `module: CommonJS` specifically; that relaxation is encoded inside
186
+ * `isBundlerCompatibleModuleKind` via a runtime version check, so on
187
+ * TS ≥ 6 user-supplied Bundler passes through unchanged on the CJS
188
+ * path.)
189
+ *
190
+ * - Anything else (Node10 / Classic / unset) passes through or falls back
191
+ * to Node10. These pairings are valid with every forced module kind.
192
+ *
193
+ * Compatibility: `ModuleResolutionKind.Bundler` was introduced in
194
+ * TypeScript 5.0. ts-jest declares `peerDependencies: { typescript: ">=4.3 <7" }`,
195
+ * so the Bundler member is `undefined` at runtime on TypeScript 4.3 - 4.9.
196
+ * The Node16/NodeNext substitution falls back to Node10 in that case
197
+ * (`bundlerResolution` below) to keep the function deterministic across the
198
+ * full supported range. Users on TypeScript < 5 can never have set Bundler in
199
+ * tsconfig (the parser rejects it), so the user-supplied-Bundler branch is
200
+ * unreachable there and needs no separate guard.
201
+ */
202
+ resolveCompatibleModuleResolution(forcedModule, userResolution) {
203
+ const node10Default = this._ts.ModuleResolutionKind.Node10 ?? this._ts.ModuleResolutionKind.NodeJs;
204
+ if (userResolution === undefined) {
205
+ return node10Default;
206
+ }
207
+ const { Node16, NodeNext, Bundler } = this._ts.ModuleResolutionKind;
208
+ const bundlerResolution = Bundler ?? node10Default;
209
+ const canUseBundler = this.isBundlerCompatibleModuleKind(forcedModule);
210
+ if (userResolution === Node16 || userResolution === NodeNext) {
211
+ return canUseBundler ? bundlerResolution : node10Default;
212
+ }
213
+ if (userResolution === Bundler && !canUseBundler) {
214
+ return node10Default;
215
+ }
216
+ return userResolution;
217
+ }
218
+ /**
219
+ * TypeScript pairs `moduleResolution: bundler` only with ES-module module
220
+ * kinds (`ES2015` / `ES2020` / `ES2022` / `ESNext`) or `Preserve` (added in
221
+ * TypeScript 5.4). Pairing `bundler` with `CommonJS`, `AMD`, `UMD`, `System`,
222
+ * or `None` raises TS5095. Used by `resolveCompatibleModuleResolution` to
223
+ * gate the `Node16` / `NodeNext` → `Bundler` substitution and the
224
+ * user-supplied-`Bundler` pass-through, so neither path emits an invalid
225
+ * pair when the user has selected a non-ES `module`.
226
+ *
227
+ * TypeScript 6.0 relaxed TS5095 for `module: CommonJS` specifically
228
+ * (`CommonJS` + `Bundler` is a valid pair on TS ≥ 6); the other non-ES
229
+ * module kinds (`AMD` / `UMD` / `System` / `None`) remain Bundler-incompatible
230
+ * on every TypeScript version. The version is detected at runtime from
231
+ * `this._ts.version` so the function stays correct across the full
232
+ * peerDependency range (`>=4.3 <7`).
233
+ *
234
+ * @see https://www.typescriptlang.org/tsconfig/#moduleResolution
235
+ */
236
+ isBundlerCompatibleModuleKind(moduleKind) {
237
+ const M = this._ts.ModuleKind;
238
+ if (moduleKind === M.ESNext || moduleKind === M.ES2015 || moduleKind === M.ES2020 || moduleKind === M.ES2022) {
239
+ return true;
240
+ }
241
+ // `ModuleKind.Preserve` was introduced in TypeScript 5.4; on older
242
+ // TypeScript versions the property is `undefined` at runtime.
243
+ if (M.Preserve !== undefined && moduleKind === M.Preserve) {
244
+ return true;
245
+ }
246
+ // TS 6 made `CommonJS` + `Bundler` a valid pair.
247
+ if (moduleKind === M.CommonJS) {
248
+ const tsMajor = parseInt(this._ts.version.split('.')[0], 10);
249
+ return tsMajor >= 6;
250
+ }
251
+ return false;
252
+ }
253
+ /**
254
+ * Pass `customConditions` through unchanged when the resolved
255
+ * `moduleResolution` is one of the kinds that supports it (`Bundler`,
256
+ * `Node16`, `NodeNext`); strip it otherwise. TypeScript raises TS5098
257
+ * when `customConditions` is paired with any other resolution kind
258
+ * (verified empirically against TypeScript 5.9.3 with `tsc -p`).
259
+ *
260
+ * Before #4198 the surrounding `fixupCompilerOptionsForModuleKind`
261
+ * unconditionally cleared `customConditions` because the hardcoded
262
+ * `Node10` override always made it incompatible. After #4198 the
263
+ * resolved `moduleResolution` can be `Bundler` (e.g. when the user
264
+ * has `Node16`/`NodeNext` paired with an ES-family `module`), so we
265
+ * need to preserve the user's `customConditions` in that case rather
266
+ * than silently dropping it.
267
+ *
268
+ * @see https://www.typescriptlang.org/tsconfig/#customConditions
269
+ */
270
+ preserveCustomConditionsIfCompatible(resolvedModuleResolution, userCustomConditions) {
271
+ const R = this._ts.ModuleResolutionKind;
272
+ const supportsCustomConditions = resolvedModuleResolution === R.Bundler ||
273
+ resolvedModuleResolution === R.Node16 ||
274
+ resolvedModuleResolution === R.NodeNext;
275
+ return supportsCustomConditions ? userCustomConditions : undefined;
276
+ }
140
277
  getCompiledOutput(fileContent, fileName, options) {
141
278
  const isEsmMode = this.configSet.useESM && options.supportsStaticESM;
142
279
  this._compilerOptions = this.fixupCompilerOptionsForModuleKind(this._initialCompilerOptions, isEsmMode);
143
280
  const moduleKind = this._initialCompilerOptions.module;
144
281
  const currentModuleKind = this._compilerOptions.module;
282
+ // Without this, a Program rebuilt for one compile's module kind would be
283
+ // reused on the next compile when that compile expects a different kind.
284
+ const moduleKindChangedSinceLastCompile = this._previousCompiledModuleKind !== undefined && this._previousCompiledModuleKind !== currentModuleKind;
285
+ this._previousCompiledModuleKind = currentModuleKind;
145
286
  if (this._languageService) {
146
287
  if (constants_1.JS_JSX_REGEX.test(fileName) && !this._compilerOptions.allowJs) {
147
288
  this._logger.warn({ fileName: fileName }, (0, messages_1.interpolate)("Got a `.js` file to compile while `allowJs` option is not set to `true` (file: {{path}}). To fix this:\n - if you want TypeScript to process JS files, set `allowJs` to `true` in your TypeScript config (usually tsconfig.json)\n - if you do not want TypeScript to process your `.js` files, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match `.js` files anymore" /* Errors.GotJsFileButAllowJsFalse */, { path: fileName }));
@@ -151,7 +292,7 @@ class TsCompiler {
151
292
  }
152
293
  this._logger.debug({ fileName }, 'getCompiledOutput(): compiling using language service');
153
294
  // Must set memory cache before attempting to compile
154
- this._updateMemoryCache(fileContent, fileName, currentModuleKind === moduleKind);
295
+ this._updateMemoryCache(fileContent, fileName, currentModuleKind === moduleKind && !moduleKindChangedSinceLastCompile);
155
296
  const output = this._languageService.getEmitOutput(fileName);
156
297
  const diagnostics = this.getDiagnostics(fileName);
157
298
  if ((0, transpile_module_1.isModernNodeModuleKind)(this._initialCompilerOptions.module)) {
@@ -360,11 +501,17 @@ class TsCompiler {
360
501
  * @internal
361
502
  */
362
503
  _resolveModuleName(moduleNameToResolve, containingFile) {
504
+ const getImpliedNodeFormat = this._ts.getImpliedNodeFormatForFile;
505
+ const resolutionMode = typeof getImpliedNodeFormat === 'function'
506
+ ? getImpliedNodeFormat(containingFile, undefined,
507
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
508
+ this._moduleResolutionHost, this._compilerOptions)
509
+ : undefined;
363
510
  return this._ts.resolveModuleName(moduleNameToResolve, containingFile, this._compilerOptions,
364
511
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
365
512
  this._moduleResolutionHost,
366
513
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
367
- this._moduleResolutionCache);
514
+ this._moduleResolutionCache, undefined, resolutionMode);
368
515
  }
369
516
  /**
370
517
  * @internal
@@ -189,11 +189,14 @@ class TsJestTransformer {
189
189
  const transpiledResult = typescript_1.default.transpileModule(sourceText, {
190
190
  compilerOptions: {
191
191
  ...configs.parsedTsConfig.options,
192
- module: transformOptions.supportsStaticESM && transformOptions.transformerConfig.useESM
192
+ module: transformOptions.supportsStaticESM && transformOptions.transformerConfig?.useESM
193
193
  ? typescript_1.default.ModuleKind.ESNext
194
194
  : typescript_1.default.ModuleKind.CommonJS,
195
195
  },
196
- fileName: sourcePath,
196
+ // .mjs fileName causes ts.transpileModule to preserve ESM syntax even with module: CommonJS
197
+ fileName: transformOptions.supportsStaticESM && transformOptions.transformerConfig?.useESM
198
+ ? sourcePath
199
+ : sourcePath.replace(/\.mjs$/, '.js'),
197
200
  });
198
201
  result = {
199
202
  code: (0, compiler_utils_1.updateOutput)(transpiledResult.outputText, sourcePath, transpiledResult.sourceMapText),
@@ -62,10 +62,17 @@ function factory({ configSet }) {
62
62
  if (statements.length <= 1) {
63
63
  return statements;
64
64
  }
65
- return statements.sort((stmtA, stmtB) => isJestGlobalImport(stmtA) ||
66
- (isHoistableStatement(stmtA) && !isHoistableStatement(stmtB) && !isJestGlobalImport(stmtB))
67
- ? -1
68
- : 1);
65
+ // Return 0 for same-category statements so stable sort preserves source
66
+ // order, the previous `-1 | 1`-only comparator violated ECMA's consistent
67
+ // comparison contract and let V8 reorder same-category pairs.
68
+ const priority = (stmt) => {
69
+ if (isJestGlobalImport(stmt))
70
+ return 0;
71
+ if (isHoistableStatement(stmt))
72
+ return 1;
73
+ return 2;
74
+ };
75
+ return statements.sort((a, b) => priority(a) - priority(b));
69
76
  };
70
77
  const createVisitor = (ctx, _) => {
71
78
  const visitor = (node) => {
package/npm-view.err ADDED
@@ -0,0 +1,9 @@
1
+ npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
2
+ npm error code E404
3
+ npm error 404 No match found for version 29.4.11
4
+ npm error 404
5
+ npm error 404 The requested resource 'ts-jest@29.4.11' could not be found or you do not have permission to access it.
6
+ npm error 404
7
+ npm error 404 Note that you can also install from a
8
+ npm error 404 tarball, folder, http url, or git url.
9
+ npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2026-05-21T13_47_16_595Z-debug-0.log
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-jest",
3
- "version": "29.4.9",
3
+ "version": "29.4.11",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "commonjs",
@@ -57,7 +57,7 @@
57
57
  "json5": "^2.2.3",
58
58
  "lodash.memoize": "^4.1.2",
59
59
  "make-error": "^1.3.6",
60
- "semver": "^7.7.4",
60
+ "semver": "^7.8.0",
61
61
  "type-fest": "^4.41.0",
62
62
  "yargs-parser": "^21.1.1"
63
63
  },
@@ -96,9 +96,9 @@
96
96
  "@eslint/compat": "^1.4.1",
97
97
  "@eslint/eslintrc": "^3.3.5",
98
98
  "@eslint/js": "^9.39.4",
99
- "@jest/globals": "^30.3.0",
100
- "@jest/transform": "^30.3.0",
101
- "@jest/types": "^30.3.0",
99
+ "@jest/globals": "^30.4.1",
100
+ "@jest/transform": "^30.4.1",
101
+ "@jest/types": "^30.4.1",
102
102
  "@types/babel__core": "^7.20.5",
103
103
  "@types/fs-extra": "^11.0.4",
104
104
  "@types/jest": "^29.5.14",
@@ -107,16 +107,16 @@
107
107
  "@types/lodash.memoize": "^4.1.9",
108
108
  "@types/lodash.set": "^4.3.9",
109
109
  "@types/micromatch": "^4.0.10",
110
- "@types/node": "20.19.37",
110
+ "@types/node": "20.19.41",
111
111
  "@types/semver": "^7.7.1",
112
112
  "@types/yargs": "^17.0.35",
113
113
  "@types/yargs-parser": "21.0.3",
114
- "@typescript-eslint/eslint-plugin": "^8.57.2",
115
- "@typescript-eslint/parser": "^8.57.2",
116
- "babel-jest": "^30.3.0",
117
- "conventional-changelog-angular": "^8.3.0",
114
+ "@typescript-eslint/eslint-plugin": "^8.59.3",
115
+ "@typescript-eslint/parser": "^8.59.3",
116
+ "babel-jest": "^30.4.1",
117
+ "conventional-changelog-angular": "^8.3.1",
118
118
  "conventional-changelog": "^7.2.0",
119
- "esbuild": "~0.27.4",
119
+ "esbuild": "~0.28.0",
120
120
  "eslint": "^9.39.4",
121
121
  "eslint-config-prettier": "^10.1.8",
122
122
  "eslint-plugin-import": "^2.32.0",
@@ -125,18 +125,18 @@
125
125
  "eslint-plugin-prettier": "^4.2.5",
126
126
  "execa": "5.1.1",
127
127
  "fast-glob": "^3.3.3",
128
- "fs-extra": "^11.3.4",
128
+ "fs-extra": "^11.3.5",
129
129
  "globals": "^16.5.0",
130
130
  "husky": "^9.1.7",
131
- "jest": "^30.3.0",
131
+ "jest": "^30.4.2",
132
132
  "js-yaml": "^4.1.1",
133
133
  "lint-staged": "^15.5.2",
134
- "memfs": "^4.57.1",
134
+ "memfs": "^4.57.2",
135
135
  "prettier": "^2.8.8",
136
136
  "rimraf": "^5.0.10",
137
137
  "ts-node": "^10.9.2",
138
138
  "typescript": "~5.9.3",
139
- "typescript-eslint": "^8.57.2"
139
+ "typescript-eslint": "^8.59.3"
140
140
  },
141
141
  "engines": {
142
142
  "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0"