ts-jest 29.3.0 → 29.3.1
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 +1 -1
- package/CHANGELOG.md +10 -0
- package/dist/legacy/compiler/ts-compiler.d.ts +1 -2
- package/dist/legacy/compiler/ts-compiler.js +13 -15
- package/dist/legacy/config/config-set.js +2 -2
- package/dist/transpilers/typescript/transpile-module.d.ts +5 -1
- package/dist/transpilers/typescript/transpile-module.js +21 -8
- package/package.json +7 -7
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
7d82f2afd50b1c1f02bc1970a3b39858b238dbf9
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [29.3.1](https://github.com/kulshekhar/ts-jest/compare/v29.3.0...v29.3.1) (2025-03-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fix: allow `isolatedModules` mode to have `ts.Program` under `Node16/Next` ([25157eb](https://github.com/kulshekhar/ts-jest/commit/25157eb))
|
|
7
|
+
* fix: improve message for `isolatedModules` of `ts-jest` config ([547eb6f](https://github.com/kulshekhar/ts-jest/commit/547eb6f))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
1
11
|
## [29.3.0](https://github.com/kulshekhar/ts-jest/compare/v29.2.6...v29.3.0) (2025-03-21)
|
|
2
12
|
|
|
3
13
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Logger } from 'bs-logger';
|
|
2
2
|
import { CompilerOptions, CustomTransformers, Program, TranspileOutput } from 'typescript';
|
|
3
|
-
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript } from '../../types';
|
|
4
|
-
import { CompiledOutput } from '../../types';
|
|
3
|
+
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript, CompiledOutput } from '../../types';
|
|
5
4
|
import type { ConfigSet } from '../config/config-set';
|
|
6
5
|
export declare class TsCompiler implements TsCompilerInstance {
|
|
7
6
|
readonly configSet: ConfigSet;
|
|
@@ -56,21 +56,10 @@ var bs_logger_1 = require("bs-logger");
|
|
|
56
56
|
var lodash_memoize_1 = __importDefault(require("lodash.memoize"));
|
|
57
57
|
var typescript_1 = __importDefault(require("typescript"));
|
|
58
58
|
var constants_1 = require("../../constants");
|
|
59
|
-
// import { tsTranspileModule } from '../../transpilers/typescript/transpile-module'
|
|
60
59
|
var transpile_module_1 = require("../../transpilers/typescript/transpile-module");
|
|
61
60
|
var utils_1 = require("../../utils");
|
|
62
61
|
var messages_1 = require("../../utils/messages");
|
|
63
62
|
var compiler_utils_1 = require("./compiler-utils");
|
|
64
|
-
var isModernNodeResolution = function (module) {
|
|
65
|
-
return module ? [typescript_1.default.ModuleKind.Node16, /* ModuleKind.Node18 */ 101, typescript_1.default.ModuleKind.NodeNext].includes(module) : false;
|
|
66
|
-
};
|
|
67
|
-
var shouldUseNativeTsTranspile = function (compilerOptions) {
|
|
68
|
-
if (!compilerOptions) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
var module = compilerOptions.module;
|
|
72
|
-
return !isModernNodeResolution(module);
|
|
73
|
-
};
|
|
74
63
|
var assertCompilerOptionsWithJestTransformMode = function (compilerOptions, isEsmMode, logger) {
|
|
75
64
|
if (isEsmMode && compilerOptions.module === typescript_1.default.ModuleKind.CommonJS) {
|
|
76
65
|
logger.error("The current compiler option \"module\" value is not suitable for Jest ESM mode. Please either use ES module kinds or Node16/NodeNext module kinds with \"type: module\" in package.json" /* Errors.InvalidModuleKindForEsm */);
|
|
@@ -142,7 +131,7 @@ var TsCompiler = /** @class */ (function () {
|
|
|
142
131
|
}
|
|
143
132
|
var moduleKind = (_b = compilerOptions.module) !== null && _b !== void 0 ? _b : this._ts.ModuleKind.ESNext;
|
|
144
133
|
var esModuleInterop = compilerOptions.esModuleInterop;
|
|
145
|
-
if (
|
|
134
|
+
if ((0, transpile_module_1.isModernNodeModuleKind)(moduleKind)) {
|
|
146
135
|
esModuleInterop = true;
|
|
147
136
|
moduleKind = this._ts.ModuleKind.ESNext;
|
|
148
137
|
}
|
|
@@ -156,7 +145,7 @@ var TsCompiler = /** @class */ (function () {
|
|
|
156
145
|
var e_1, _a;
|
|
157
146
|
var isEsmMode = this.configSet.useESM && options.supportsStaticESM;
|
|
158
147
|
this._compilerOptions = this.fixupCompilerOptionsForModuleKind(this._initialCompilerOptions, isEsmMode);
|
|
159
|
-
if (!this._initialCompilerOptions.isolatedModules &&
|
|
148
|
+
if (!this._initialCompilerOptions.isolatedModules && (0, transpile_module_1.isModernNodeModuleKind)(this._initialCompilerOptions.module)) {
|
|
160
149
|
this._logger.warn("Using hybrid module kind (Node16/18/Next) is only supported in \"isolatedModules: true\". Please set \"isolatedModules: true\" in your tsconfig.json." /* Helps.UsingModernNodeResolution */);
|
|
161
150
|
}
|
|
162
151
|
var moduleKind = this._initialCompilerOptions.module;
|
|
@@ -235,7 +224,13 @@ var TsCompiler = /** @class */ (function () {
|
|
|
235
224
|
}
|
|
236
225
|
};
|
|
237
226
|
TsCompiler.prototype._transpileOutput = function (fileContent, fileName) {
|
|
238
|
-
|
|
227
|
+
var _this = this;
|
|
228
|
+
/**
|
|
229
|
+
* @deprecated
|
|
230
|
+
*
|
|
231
|
+
* This code path should be removed in the next major version to benefit from checking on compiler options
|
|
232
|
+
*/
|
|
233
|
+
if (!(0, transpile_module_1.isModernNodeModuleKind)(this._initialCompilerOptions.module)) {
|
|
239
234
|
return this._ts.transpileModule(fileContent, {
|
|
240
235
|
fileName: fileName,
|
|
241
236
|
transformers: this._makeTransformers(this.configSet.resolvedTransformers),
|
|
@@ -245,7 +240,10 @@ var TsCompiler = /** @class */ (function () {
|
|
|
245
240
|
}
|
|
246
241
|
return (0, transpile_module_1.tsTranspileModule)(fileContent, {
|
|
247
242
|
fileName: fileName,
|
|
248
|
-
transformers:
|
|
243
|
+
transformers: function (program) {
|
|
244
|
+
_this.program = program;
|
|
245
|
+
return _this._makeTransformers(_this.configSet.resolvedTransformers);
|
|
246
|
+
},
|
|
249
247
|
compilerOptions: this._initialCompilerOptions,
|
|
250
248
|
reportDiagnostics: fileName ? this.configSet.shouldReportDiagnostics(fileName) : false,
|
|
251
249
|
});
|
|
@@ -225,12 +225,12 @@ var ConfigSet = /** @class */ (function () {
|
|
|
225
225
|
if (options.isolatedModules) {
|
|
226
226
|
this.parsedTsConfig.options.isolatedModules = true;
|
|
227
227
|
if (this.tsconfigFilePath) {
|
|
228
|
-
this.logger.warn((0, messages_1.interpolate)("\"isolatedModules\" is deprecated and will be removed in v30.0.0. Please
|
|
228
|
+
this.logger.warn((0, messages_1.interpolate)("\n The \"ts-jest\" config option \"isolatedModules\" is deprecated and will be removed in v30.0.0. Please use \"isolatedModules: true\" in {{tsconfigFilePath}} instead, see https://www.typescriptlang.org/tsconfig/#isolatedModules\n " /* Deprecations.IsolatedModulesWithTsconfigPath */, {
|
|
229
229
|
tsconfigFilePath: this.tsconfigFilePath,
|
|
230
230
|
}));
|
|
231
231
|
}
|
|
232
232
|
else {
|
|
233
|
-
this.logger.warn("\"isolatedModules\" is deprecated and will be removed in v30.0.0. Please
|
|
233
|
+
this.logger.warn("\n The \"ts-jest\" config option \"isolatedModules\" is deprecated and will be removed in v30.0.0. Please use \"isolatedModules: true\", see https://www.typescriptlang.org/tsconfig/#isolatedModules\n " /* Deprecations.IsolatedModulesWithoutTsconfigPath */);
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
this.isolatedModules = (_f = this.parsedTsConfig.options.isolatedModules) !== null && _f !== void 0 ? _f : false;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
type
|
|
2
|
+
type ExtendedTranspileOptions = Omit<ts.TranspileOptions, 'transformers'> & {
|
|
3
|
+
transformers?: (program: ts.Program) => ts.CustomTransformers;
|
|
4
|
+
};
|
|
5
|
+
type ExtendedTsTranspileModuleFn = (fileContent: string, transpileOptions: ExtendedTranspileOptions) => ts.TranspileOutput;
|
|
6
|
+
export declare const isModernNodeModuleKind: (module: ts.ModuleKind | undefined) => boolean;
|
|
3
7
|
export declare const tsTranspileModule: ExtendedTsTranspileModuleFn;
|
|
4
8
|
export {};
|
|
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.tsTranspileModule = void 0;
|
|
42
|
+
exports.tsTranspileModule = exports.isModernNodeModuleKind = void 0;
|
|
43
43
|
var node_path_1 = __importDefault(require("node:path"));
|
|
44
44
|
var typescript_1 = __importDefault(require("typescript"));
|
|
45
45
|
var messages_1 = require("../../utils/messages");
|
|
@@ -57,6 +57,13 @@ function getNewLineCharacter(options) {
|
|
|
57
57
|
return lineFeed;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
var isModernNodeModuleKind = function (module) {
|
|
61
|
+
return module ? [typescript_1.default.ModuleKind.Node16, /* ModuleKind.Node18 */ 101, typescript_1.default.ModuleKind.NodeNext].includes(module) : false;
|
|
62
|
+
};
|
|
63
|
+
exports.isModernNodeModuleKind = isModernNodeModuleKind;
|
|
64
|
+
var shouldCheckProjectPkgJsonContent = function (fileName, moduleKind) {
|
|
65
|
+
return fileName.endsWith('package.json') && (0, exports.isModernNodeModuleKind)(moduleKind);
|
|
66
|
+
};
|
|
60
67
|
/**
|
|
61
68
|
* Copy source code of {@link ts.transpileModule} from {@link https://github.com/microsoft/TypeScript/blob/main/src/services/transpile.ts}
|
|
62
69
|
* with extra modifications:
|
|
@@ -65,7 +72,7 @@ function getNewLineCharacter(options) {
|
|
|
65
72
|
*/
|
|
66
73
|
var transpileWorker = function (input, transpileOptions) {
|
|
67
74
|
var e_1, _a;
|
|
68
|
-
var _b, _c, _d, _e;
|
|
75
|
+
var _b, _c, _d, _e, _f;
|
|
69
76
|
barebonesLibSourceFile !== null && barebonesLibSourceFile !== void 0 ? barebonesLibSourceFile : (barebonesLibSourceFile = typescript_1.default.createSourceFile(barebonesLibName, barebonesLibContent, {
|
|
70
77
|
languageVersion: typescript_1.default.ScriptTarget.Latest,
|
|
71
78
|
}));
|
|
@@ -83,8 +90,8 @@ var transpileWorker = function (input, transpileOptions) {
|
|
|
83
90
|
}
|
|
84
91
|
try {
|
|
85
92
|
// @ts-expect-error internal TypeScript API
|
|
86
|
-
for (var
|
|
87
|
-
var option =
|
|
93
|
+
for (var _g = __values(typescript_1.default.transpileOptionValueCompilerOptions), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
94
|
+
var option = _h.value;
|
|
88
95
|
// Do not set redundant config options if `verbatimModuleSyntax` was supplied.
|
|
89
96
|
if (options.verbatimModuleSyntax && new Set(['isolatedModules']).has(option.name)) {
|
|
90
97
|
continue;
|
|
@@ -95,7 +102,7 @@ var transpileWorker = function (input, transpileOptions) {
|
|
|
95
102
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
96
103
|
finally {
|
|
97
104
|
try {
|
|
98
|
-
if (
|
|
105
|
+
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
|
|
99
106
|
}
|
|
100
107
|
finally { if (e_1) throw e_1.error; }
|
|
101
108
|
}
|
|
@@ -132,10 +139,16 @@ var transpileWorker = function (input, transpileOptions) {
|
|
|
132
139
|
getCurrentDirectory: function () { return ''; },
|
|
133
140
|
getNewLine: function () { return newLine; },
|
|
134
141
|
fileExists: function (fileName) {
|
|
135
|
-
|
|
142
|
+
if (shouldCheckProjectPkgJsonContent(fileName, options.module)) {
|
|
143
|
+
return typescript_1.default.sys.fileExists(fileName);
|
|
144
|
+
}
|
|
145
|
+
return fileName === inputFileName;
|
|
136
146
|
},
|
|
137
147
|
readFile: function (fileName) {
|
|
138
|
-
|
|
148
|
+
if (shouldCheckProjectPkgJsonContent(fileName, options.module)) {
|
|
149
|
+
return typescript_1.default.sys.readFile(fileName);
|
|
150
|
+
}
|
|
151
|
+
return '';
|
|
139
152
|
},
|
|
140
153
|
directoryExists: function () { return true; },
|
|
141
154
|
getDirectories: function () { return []; },
|
|
@@ -169,7 +182,7 @@ var transpileWorker = function (input, transpileOptions) {
|
|
|
169
182
|
/*targetSourceFile*/ undefined,
|
|
170
183
|
/*writeFile*/ undefined,
|
|
171
184
|
/*cancellationToken*/ undefined,
|
|
172
|
-
/*emitOnlyDtsFiles*/ undefined, transpileOptions.transformers);
|
|
185
|
+
/*emitOnlyDtsFiles*/ undefined, (_f = transpileOptions.transformers) === null || _f === void 0 ? void 0 : _f.call(transpileOptions, program));
|
|
173
186
|
diagnostics.push.apply(diagnostics, __spreadArray([], __read(result.diagnostics), false));
|
|
174
187
|
if (outputText === undefined) {
|
|
175
188
|
diagnostics.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "29.3.
|
|
3
|
+
"version": "29.3.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"lodash.memoize": "^4.1.2",
|
|
60
60
|
"make-error": "^1.3.6",
|
|
61
61
|
"semver": "^7.7.1",
|
|
62
|
-
"type-fest": "^4.
|
|
62
|
+
"type-fest": "^4.38.0",
|
|
63
63
|
"yargs-parser": "^21.1.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
@@ -105,12 +105,12 @@
|
|
|
105
105
|
"@types/lodash.memoize": "^4.1.9",
|
|
106
106
|
"@types/lodash.set": "^4.3.9",
|
|
107
107
|
"@types/micromatch": "^4.0.9",
|
|
108
|
-
"@types/node": "20.17.
|
|
109
|
-
"@types/semver": "^7.
|
|
108
|
+
"@types/node": "20.17.28",
|
|
109
|
+
"@types/semver": "^7.7.0",
|
|
110
110
|
"@types/yargs": "^17.0.33",
|
|
111
111
|
"@types/yargs-parser": "21.0.3",
|
|
112
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
113
|
-
"@typescript-eslint/parser": "^8.
|
|
112
|
+
"@typescript-eslint/eslint-plugin": "^8.28.0",
|
|
113
|
+
"@typescript-eslint/parser": "^8.28.0",
|
|
114
114
|
"babel-jest": "^29.7.0",
|
|
115
115
|
"conventional-changelog-cli": "^5.0.0",
|
|
116
116
|
"esbuild": "~0.25.1",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"prettier": "^2.8.8",
|
|
134
134
|
"rimraf": "^5.0.10",
|
|
135
135
|
"typescript": "~5.5.4",
|
|
136
|
-
"typescript-eslint": "^8.
|
|
136
|
+
"typescript-eslint": "^8.28.0"
|
|
137
137
|
},
|
|
138
138
|
"engines": {
|
|
139
139
|
"node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0"
|