ts-jest 29.3.1 → 29.3.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 +1 -1
- package/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/dist/legacy/compiler/ts-compiler.js +6 -0
- package/dist/legacy/ts-jest-transformer.d.ts +0 -3
- package/dist/legacy/ts-jest-transformer.js +24 -16
- package/dist/utils/json.js +0 -26
- package/package.json +14 -14
- package/sonar-project.properties +16 -0
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
f23c7d9044c4051d802f7e95e657393a9fc3c810
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [29.3.2](https://github.com/kulshekhar/ts-jest/compare/v29.3.1...v29.3.2) (2025-04-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fix: transpile `js` files from `node_modules` whenever Jest asks ([968370e](https://github.com/kulshekhar/ts-jest/commit/968370e)), closes [#4637](https://github.com/kulshekhar/ts-jest/issues/4637)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
## [29.3.1](https://github.com/kulshekhar/ts-jest/compare/v29.3.0...v29.3.1) (2025-03-31)
|
|
2
11
|
|
|
3
12
|
|
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ See also the list of [contributors](https://github.com/kulshekhar/ts-jest/contri
|
|
|
67
67
|
|
|
68
68
|
## Supporters
|
|
69
69
|
|
|
70
|
-
- [JetBrains](https://www.jetbrains.com/?from=ts-jest) has been kind enough to support ts-jest with
|
|
70
|
+
- [JetBrains](https://www.jetbrains.com/?from=ts-jest) has been kind enough to support ts-jest with a [license for open source] (https://www.jetbrains.com/community/opensource/?from=ts-jest).
|
|
71
71
|
|
|
72
72
|
## License
|
|
73
73
|
|
|
@@ -151,6 +151,12 @@ var TsCompiler = /** @class */ (function () {
|
|
|
151
151
|
var moduleKind = this._initialCompilerOptions.module;
|
|
152
152
|
var currentModuleKind = this._compilerOptions.module;
|
|
153
153
|
if (this._languageService) {
|
|
154
|
+
if (constants_1.JS_JSX_REGEX.test(fileName) && !this._compilerOptions.allowJs) {
|
|
155
|
+
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 }));
|
|
156
|
+
return {
|
|
157
|
+
code: fileContent,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
154
160
|
this._logger.debug({ fileName: fileName }, 'getCompiledOutput(): compiling using language service');
|
|
155
161
|
// Must set memory cache before attempting to compile
|
|
156
162
|
this._updateMemoryCache(fileContent, fileName, currentModuleKind === moduleKind);
|
|
@@ -12,9 +12,6 @@ export declare class TsJestTransformer implements SyncTransformer<TsJestTransfor
|
|
|
12
12
|
private _configsFor;
|
|
13
13
|
protected _createConfigSet(config: TsJestTransformOptions['config'] | undefined): ConfigSet;
|
|
14
14
|
protected _createCompiler(configSet: ConfigSet, cacheFS: Map<string, string>): void;
|
|
15
|
-
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
15
|
process(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): TransformedSource;
|
|
19
16
|
processAsync(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): Promise<TransformedSource>;
|
|
20
17
|
private processWithTs;
|
|
@@ -78,13 +78,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
78
78
|
exports.TsJestTransformer = exports.CACHE_KEY_EL_SEPARATOR = void 0;
|
|
79
79
|
var fs_1 = require("fs");
|
|
80
80
|
var path_1 = __importDefault(require("path"));
|
|
81
|
+
var typescript_1 = __importDefault(require("typescript"));
|
|
81
82
|
var constants_1 = require("../constants");
|
|
82
83
|
var utils_1 = require("../utils");
|
|
83
84
|
var importer_1 = require("../utils/importer");
|
|
84
85
|
var messages_1 = require("../utils/messages");
|
|
85
86
|
var sha1_1 = require("../utils/sha1");
|
|
86
87
|
var compiler_1 = require("./compiler");
|
|
88
|
+
var compiler_utils_1 = require("./compiler/compiler-utils");
|
|
87
89
|
var config_set_1 = require("./config/config-set");
|
|
90
|
+
var isNodeModule = function (filePath) {
|
|
91
|
+
return path_1.default.normalize(filePath).split(path_1.default.sep).includes('node_modules');
|
|
92
|
+
};
|
|
88
93
|
/**
|
|
89
94
|
* @internal
|
|
90
95
|
*/
|
|
@@ -169,9 +174,6 @@ var TsJestTransformer = /** @class */ (function () {
|
|
|
169
174
|
TsJestTransformer.prototype._createCompiler = function (configSet, cacheFS) {
|
|
170
175
|
this._compiler = new compiler_1.TsJestCompiler(configSet, cacheFS);
|
|
171
176
|
};
|
|
172
|
-
/**
|
|
173
|
-
* @public
|
|
174
|
-
*/
|
|
175
177
|
TsJestTransformer.prototype.process = function (sourceText, sourcePath, transformOptions) {
|
|
176
178
|
this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
|
|
177
179
|
var configs = this._configsFor(transformOptions);
|
|
@@ -240,20 +242,26 @@ var TsJestTransformer = /** @class */ (function () {
|
|
|
240
242
|
code: '',
|
|
241
243
|
};
|
|
242
244
|
}
|
|
243
|
-
else if (!configs.parsedTsConfig.options.allowJs && isJsFile) {
|
|
244
|
-
// we've got a '.js' but the compiler option `allowJs` is not set or set to false
|
|
245
|
-
this._logger.warn({ fileName: sourcePath }, (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: sourcePath }));
|
|
246
|
-
result = {
|
|
247
|
-
code: sourceText,
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
245
|
else if (isJsFile || isTsFile) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
246
|
+
if (isJsFile && isNodeModule(sourcePath)) {
|
|
247
|
+
var transpiledResult = typescript_1.default.transpileModule(sourceText, {
|
|
248
|
+
compilerOptions: __assign(__assign({}, configs.parsedTsConfig.options), { module: transformOptions.supportsStaticESM && transformOptions.transformerConfig.useESM
|
|
249
|
+
? typescript_1.default.ModuleKind.ESNext
|
|
250
|
+
: typescript_1.default.ModuleKind.CommonJS }),
|
|
251
|
+
fileName: sourcePath,
|
|
252
|
+
});
|
|
253
|
+
result = {
|
|
254
|
+
code: (0, compiler_utils_1.updateOutput)(transpiledResult.outputText, sourcePath, transpiledResult.sourceMapText),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
// transpile TS code (source maps are included)
|
|
259
|
+
result = this._compiler.getCompiledOutput(sourceText, sourcePath, {
|
|
260
|
+
depGraphs: this._depGraphs,
|
|
261
|
+
supportsStaticESM: transformOptions.supportsStaticESM,
|
|
262
|
+
watchMode: this._watchMode,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
257
265
|
}
|
|
258
266
|
else {
|
|
259
267
|
// we should not get called for files with other extension than js[x], ts[x] and d.ts,
|
package/dist/utils/json.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.stringify = stringify;
|
|
7
7
|
exports.parse = parse;
|
|
8
|
-
exports.normalize = normalize;
|
|
9
8
|
var fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
|
10
9
|
var UNDEFINED = 'undefined';
|
|
11
10
|
function stringify(input) {
|
|
@@ -15,28 +14,3 @@ function stringify(input) {
|
|
|
15
14
|
function parse(input) {
|
|
16
15
|
return input === UNDEFINED ? undefined : JSON.parse(input);
|
|
17
16
|
}
|
|
18
|
-
/**
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
function normalize(input, _a) {
|
|
22
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.parse, parser = _c === void 0 ? parse : _c;
|
|
23
|
-
var result;
|
|
24
|
-
if (normalize.cache.has(input)) {
|
|
25
|
-
result = normalize.cache.get(input);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
var data = parser(input);
|
|
29
|
-
result = stringify(data);
|
|
30
|
-
if (result === input)
|
|
31
|
-
result = undefined;
|
|
32
|
-
normalize.cache.set(input, result);
|
|
33
|
-
}
|
|
34
|
-
return result !== null && result !== void 0 ? result : input;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
40
|
-
(function (normalize) {
|
|
41
|
-
normalize.cache = new Map();
|
|
42
|
-
})(normalize || (exports.normalize = normalize = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "29.3.
|
|
3
|
+
"version": "29.3.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"build": "tsc -p tsconfig.build.json",
|
|
14
14
|
"postbuild": "node scripts/post-build.js",
|
|
15
15
|
"test": "jest -c=jest.config.ts",
|
|
16
|
-
"test-e2e-cjs": "jest -c=jest-e2e.config.
|
|
17
|
-
"test-e2e-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-e2e.config.
|
|
16
|
+
"test-e2e-cjs": "jest -c=jest-e2e-cjs.config.ts --no-cache",
|
|
17
|
+
"test-e2e-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-e2e-esm.config.ts --no-cache",
|
|
18
18
|
"test-examples": "node scripts/test-examples.js",
|
|
19
19
|
"lint": "eslint .",
|
|
20
20
|
"lint-fix": "eslint --fix .",
|
|
@@ -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.39.1",
|
|
63
63
|
"yargs-parser": "^21.1.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
@@ -90,9 +90,9 @@
|
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@commitlint/cli": "^19.8.0",
|
|
92
92
|
"@commitlint/config-angular": "^19.8.0",
|
|
93
|
-
"@eslint/compat": "^1.2.
|
|
93
|
+
"@eslint/compat": "^1.2.8",
|
|
94
94
|
"@eslint/eslintrc": "^3.3.1",
|
|
95
|
-
"@eslint/js": "^9.
|
|
95
|
+
"@eslint/js": "^9.24.0",
|
|
96
96
|
"@jest/globals": "^29.7.0",
|
|
97
97
|
"@jest/transform": "^29.7.0",
|
|
98
98
|
"@jest/types": "^29.6.3",
|
|
@@ -105,17 +105,17 @@
|
|
|
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.
|
|
108
|
+
"@types/node": "20.17.30",
|
|
109
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.29.1",
|
|
113
|
+
"@typescript-eslint/parser": "^8.29.1",
|
|
114
114
|
"babel-jest": "^29.7.0",
|
|
115
115
|
"conventional-changelog-cli": "^5.0.0",
|
|
116
|
-
"esbuild": "~0.25.
|
|
117
|
-
"eslint": "^9.
|
|
118
|
-
"eslint-config-prettier": "^10.1.
|
|
116
|
+
"esbuild": "~0.25.2",
|
|
117
|
+
"eslint": "^9.24.0",
|
|
118
|
+
"eslint-config-prettier": "^10.1.2",
|
|
119
119
|
"eslint-plugin-import": "^2.31.0",
|
|
120
120
|
"eslint-plugin-jest": "^28.11.0",
|
|
121
121
|
"eslint-plugin-jsdoc": "^50.6.9",
|
|
@@ -128,12 +128,12 @@
|
|
|
128
128
|
"husky": "^9.1.7",
|
|
129
129
|
"jest": "^29.7.0",
|
|
130
130
|
"js-yaml": "^4.1.0",
|
|
131
|
-
"lint-staged": "^15.5.
|
|
131
|
+
"lint-staged": "^15.5.1",
|
|
132
132
|
"memfs": "^4.17.0",
|
|
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.29.1"
|
|
137
137
|
},
|
|
138
138
|
"engines": {
|
|
139
139
|
"node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
sonar.organization=kulshekhar-ts-jest
|
|
2
|
+
sonar.projectKey=kulshekhar_ts-jest
|
|
3
|
+
sonar.sources=src
|
|
4
|
+
sonar.language=ts
|
|
5
|
+
sonar.sourceEncoding=UTF-8
|
|
6
|
+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
7
|
+
sonar.typescript.tsconfigPath=tsconfig.json
|
|
8
|
+
sonar.exclusions=\
|
|
9
|
+
**/*.md, \
|
|
10
|
+
**/jest.config.ts, \
|
|
11
|
+
**/jest-*.config.ts, \
|
|
12
|
+
**/*.spec.ts, \
|
|
13
|
+
**/**.spec.ts, \
|
|
14
|
+
src/__helpers__/**, \
|
|
15
|
+
src/__mocks__/**, \
|
|
16
|
+
website/**
|