ts-jest 29.1.2 → 29.1.4
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 +29 -0
- package/dist/cli/config/init.js +3 -2
- package/dist/constants.js +2 -2
- package/dist/legacy/ts-jest-transformer.d.ts +0 -5
- package/dist/legacy/ts-jest-transformer.js +1 -22
- package/package.json +34 -30
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
bdc3f261ac17efdeccd11ccec4d3ce6c393abe5d
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## [29.1.4](https://github.com/kulshekhar/ts-jest/compare/v29.1.3...v29.1.4) (2024-05-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fix(transformer): allow transforming of .cts/.mts extensions. (#3996) ([b8f6eaa](https://github.com/kulshekhar/ts-jest/commit/b8f6eaa)), closes [#3996](https://github.com/kulshekhar/ts-jest/issues/3996)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* feat: make cli generate esm config based on `type: "module"` (#4210) ([81a5f64](https://github.com/kulshekhar/ts-jest/commit/81a5f64)), closes [#4210](https://github.com/kulshekhar/ts-jest/issues/4210) [#4012](https://github.com/kulshekhar/ts-jest/issues/4012)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [29.1.3](https://github.com/kulshekhar/ts-jest/compare/v29.1.2...v29.1.3) (2024-05-21)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* add `@jest/transform` as an optional peer dependency ([0ba7f86](https://github.com/kulshekhar/ts-jest/commit/0ba7f861c3e1905de5627b4e5d2a2cadad011b67))
|
|
21
|
+
* bring back Node 14 support ([eda56a7](https://github.com/kulshekhar/ts-jest/commit/eda56a779789d70963b7572e2914b2a3a25ac43a))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Performance Improvements
|
|
25
|
+
|
|
26
|
+
* remove ts resolved module cache file ([4c88da5](https://github.com/kulshekhar/ts-jest/commit/4c88da58991b000aa90ea489acfa6aed39b36120))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
1
30
|
## [29.1.2](https://github.com/kulshekhar/ts-jest/compare/v29.1.1...v29.1.2) (2024-01-22)
|
|
2
31
|
|
|
3
32
|
|
package/dist/cli/config/init.js
CHANGED
|
@@ -77,7 +77,7 @@ var presets_1 = require("../helpers/presets");
|
|
|
77
77
|
* @internal
|
|
78
78
|
*/
|
|
79
79
|
var run = function (args /* , logger: Logger */) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
-
var file, filePath, name, isPackage, exists, pkgFile, hasPackage, _a, jestPreset, askedTsconfig, force, jsdom, tsconfig, pkgJson, jsFilesProcessor, shouldPostProcessWithBabel, preset, body, jestConfig, transformerConfig, content;
|
|
80
|
+
var file, filePath, name, isPackage, exists, pkgFile, hasPackage, _a, jestPreset, askedTsconfig, force, jsdom, tsconfig, pkgJson, jsFilesProcessor, shouldPostProcessWithBabel, preset, body, jestConfig, transformerConfig, content, usesModules;
|
|
81
81
|
var _b, _c, _d;
|
|
82
82
|
return __generator(this, function (_e) {
|
|
83
83
|
file = (_c = (_b = args._[0]) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : 'jest.config.js';
|
|
@@ -157,7 +157,8 @@ var run = function (args /* , logger: Logger */) { return __awaiter(void 0, void
|
|
|
157
157
|
content.push("".concat(preset.jsImport('tsjPreset'), ";"), '');
|
|
158
158
|
}
|
|
159
159
|
content.push("/** @type {import('ts-jest').JestConfigWithTsJest} */");
|
|
160
|
-
|
|
160
|
+
usesModules = pkgJson.type === 'module';
|
|
161
|
+
content.push(usesModules ? 'export default {' : 'module.exports = {');
|
|
161
162
|
if (jestPreset) {
|
|
162
163
|
content.push(" preset: '".concat(preset.name, "',"));
|
|
163
164
|
}
|
package/dist/constants.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.DEFAULT_JEST_TEST_MATCH = exports.JS_EXT_TO_TREAT_AS_ESM = exports.TS_EX
|
|
|
4
4
|
exports.LINE_FEED = '\n';
|
|
5
5
|
exports.DECLARATION_TYPE_EXT = '.d.ts';
|
|
6
6
|
exports.JS_JSX_EXTENSIONS = ['.js', '.jsx'];
|
|
7
|
-
exports.TS_TSX_REGEX = /\.
|
|
8
|
-
exports.JS_JSX_REGEX = /\.
|
|
7
|
+
exports.TS_TSX_REGEX = /\.[cm]?tsx?$/;
|
|
8
|
+
exports.JS_JSX_REGEX = /\.[cm]?jsx?$/;
|
|
9
9
|
// `extensionsToTreatAsEsm` will throw error with `.mjs`
|
|
10
10
|
exports.TS_EXT_TO_TREAT_AS_ESM = ['.ts', '.tsx', '.mts'];
|
|
11
11
|
exports.JS_EXT_TO_TREAT_AS_ESM = ['.jsx'];
|
|
@@ -5,7 +5,6 @@ export declare class TsJestTransformer implements SyncTransformer<TsJestTransfor
|
|
|
5
5
|
private readonly tsJestConfig?;
|
|
6
6
|
private readonly _logger;
|
|
7
7
|
protected _compiler: CompilerInstance;
|
|
8
|
-
private _tsResolvedModulesCachePath;
|
|
9
8
|
private _transformCfgStr;
|
|
10
9
|
private _depGraphs;
|
|
11
10
|
private _watchMode;
|
|
@@ -29,8 +28,4 @@ export declare class TsJestTransformer implements SyncTransformer<TsJestTransfor
|
|
|
29
28
|
*/
|
|
30
29
|
getCacheKey(fileContent: string, filePath: string, transformOptions: TsJestTransformOptions): string;
|
|
31
30
|
getCacheKeyAsync(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): Promise<string>;
|
|
32
|
-
/**
|
|
33
|
-
* Subclasses extends `TsJestTransformer` can call this method to get resolved module disk cache
|
|
34
|
-
*/
|
|
35
|
-
private _getFsCachedResolvedModules;
|
|
36
31
|
}
|
|
@@ -117,7 +117,6 @@ var TsJestTransformer = exports.TsJestTransformer = /** @class */ (function () {
|
|
|
117
117
|
this._transformCfgStr = ccs.transformerCfgStr;
|
|
118
118
|
this._compiler = ccs.compiler;
|
|
119
119
|
this._depGraphs = ccs.depGraphs;
|
|
120
|
-
this._tsResolvedModulesCachePath = ccs.tsResolvedModulesCachePath;
|
|
121
120
|
this._watchMode = ccs.watchMode;
|
|
122
121
|
configSet = ccs.configSet;
|
|
123
122
|
}
|
|
@@ -133,7 +132,6 @@ var TsJestTransformer = exports.TsJestTransformer = /** @class */ (function () {
|
|
|
133
132
|
this._transformCfgStr = serializedCcs.transformerCfgStr;
|
|
134
133
|
this._compiler = serializedCcs.compiler;
|
|
135
134
|
this._depGraphs = serializedCcs.depGraphs;
|
|
136
|
-
this._tsResolvedModulesCachePath = serializedCcs.tsResolvedModulesCachePath;
|
|
137
135
|
this._watchMode = serializedCcs.watchMode;
|
|
138
136
|
configSet = serializedCcs.configSet;
|
|
139
137
|
}
|
|
@@ -154,7 +152,6 @@ var TsJestTransformer = exports.TsJestTransformer = /** @class */ (function () {
|
|
|
154
152
|
jest_1.cacheDirectory = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
155
153
|
this._transformCfgStr = "".concat(new utils_1.JsonableValue(jest_1).serialized).concat(configSet.cacheSuffix);
|
|
156
154
|
this._createCompiler(configSet, cacheFS);
|
|
157
|
-
this._getFsCachedResolvedModules(configSet);
|
|
158
155
|
this._watchMode = process.argv.includes('--watch');
|
|
159
156
|
TsJestTransformer._cachedConfigSets.push({
|
|
160
157
|
jestConfig: new utils_1.JsonableValue(config),
|
|
@@ -162,7 +159,6 @@ var TsJestTransformer = exports.TsJestTransformer = /** @class */ (function () {
|
|
|
162
159
|
transformerCfgStr: this._transformCfgStr,
|
|
163
160
|
compiler: this._compiler,
|
|
164
161
|
depGraphs: this._depGraphs,
|
|
165
|
-
tsResolvedModulesCachePath: this._tsResolvedModulesCachePath,
|
|
166
162
|
watchMode: this._watchMode,
|
|
167
163
|
});
|
|
168
164
|
}
|
|
@@ -319,7 +315,7 @@ var TsJestTransformer = exports.TsJestTransformer = /** @class */ (function () {
|
|
|
319
315
|
exports.CACHE_KEY_EL_SEPARATOR,
|
|
320
316
|
filePath,
|
|
321
317
|
];
|
|
322
|
-
if (!configs.isolatedModules &&
|
|
318
|
+
if (!configs.isolatedModules && configs.tsCacheDir) {
|
|
323
319
|
var resolvedModuleNames = void 0;
|
|
324
320
|
if (((_b = this._depGraphs.get(filePath)) === null || _b === void 0 ? void 0 : _b.fileContent) === fileContent) {
|
|
325
321
|
this._logger.debug({ fileName: filePath, transformOptions: transformOptions }, 'getting resolved modules from disk caching or memory caching for', filePath);
|
|
@@ -335,7 +331,6 @@ var TsJestTransformer = exports.TsJestTransformer = /** @class */ (function () {
|
|
|
335
331
|
fileContent: fileContent,
|
|
336
332
|
resolvedModuleNames: resolvedModuleNames,
|
|
337
333
|
});
|
|
338
|
-
(0, fs_1.writeFileSync)(this._tsResolvedModulesCachePath, (0, utils_1.stringify)(__spreadArray([], __read(this._depGraphs), false)));
|
|
339
334
|
}
|
|
340
335
|
resolvedModuleNames.forEach(function (moduleName) {
|
|
341
336
|
constructingCacheKeyElements.push(exports.CACHE_KEY_EL_SEPARATOR, moduleName, exports.CACHE_KEY_EL_SEPARATOR, (0, fs_1.statSync)(moduleName).mtimeMs.toString());
|
|
@@ -350,22 +345,6 @@ var TsJestTransformer = exports.TsJestTransformer = /** @class */ (function () {
|
|
|
350
345
|
});
|
|
351
346
|
});
|
|
352
347
|
};
|
|
353
|
-
/**
|
|
354
|
-
* Subclasses extends `TsJestTransformer` can call this method to get resolved module disk cache
|
|
355
|
-
*/
|
|
356
|
-
TsJestTransformer.prototype._getFsCachedResolvedModules = function (configSet) {
|
|
357
|
-
var cacheDir = configSet.tsCacheDir;
|
|
358
|
-
if (!configSet.isolatedModules && cacheDir) {
|
|
359
|
-
// Make sure the cache directory exists before continuing.
|
|
360
|
-
(0, fs_1.mkdirSync)(cacheDir, { recursive: true });
|
|
361
|
-
this._tsResolvedModulesCachePath = path_1.default.join(cacheDir, (0, sha1_1.sha1)('ts-jest-resolved-modules', exports.CACHE_KEY_EL_SEPARATOR));
|
|
362
|
-
try {
|
|
363
|
-
var cachedTSResolvedModules = (0, fs_1.readFileSync)(this._tsResolvedModulesCachePath, 'utf-8');
|
|
364
|
-
this._depGraphs = new Map((0, utils_1.parse)(cachedTSResolvedModules));
|
|
365
|
-
}
|
|
366
|
-
catch (e) { }
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
348
|
/**
|
|
370
349
|
* cache ConfigSet between test runs
|
|
371
350
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "29.1.
|
|
3
|
+
"version": "29.1.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@babel/core": ">=7.0.0-beta.0 <8",
|
|
65
|
+
"@jest/transform": "^29.0.0",
|
|
65
66
|
"@jest/types": "^29.0.0",
|
|
66
67
|
"babel-jest": "^29.0.0",
|
|
67
68
|
"jest": "^29.0.0",
|
|
@@ -71,6 +72,9 @@
|
|
|
71
72
|
"@babel/core": {
|
|
72
73
|
"optional": true
|
|
73
74
|
},
|
|
75
|
+
"@jest/transform": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
74
78
|
"@jest/types": {
|
|
75
79
|
"optional": true
|
|
76
80
|
},
|
|
@@ -89,51 +93,51 @@
|
|
|
89
93
|
}
|
|
90
94
|
},
|
|
91
95
|
"devDependencies": {
|
|
92
|
-
"@commitlint/cli": "
|
|
93
|
-
"@commitlint/config-angular": "^
|
|
94
|
-
"@jest/transform": "^29.
|
|
95
|
-
"@jest/types": "^29.
|
|
96
|
-
"@types/babel__core": "7.
|
|
96
|
+
"@commitlint/cli": "^19.3.0",
|
|
97
|
+
"@commitlint/config-angular": "^19.3.0",
|
|
98
|
+
"@jest/transform": "^29.7.0",
|
|
99
|
+
"@jest/types": "^29.6.3",
|
|
100
|
+
"@types/babel__core": "7.20.5",
|
|
97
101
|
"@types/cross-spawn": "latest",
|
|
98
102
|
"@types/fs-extra": "latest",
|
|
99
103
|
"@types/js-yaml": "latest",
|
|
100
|
-
"@types/lodash.camelcase": "4.
|
|
101
|
-
"@types/lodash.memoize": "4.
|
|
102
|
-
"@types/lodash.set": "4.
|
|
103
|
-
"@types/micromatch": "4.
|
|
104
|
-
"@types/node": "
|
|
104
|
+
"@types/lodash.camelcase": "4.3.9",
|
|
105
|
+
"@types/lodash.memoize": "4.1.9",
|
|
106
|
+
"@types/lodash.set": "4.3.9",
|
|
107
|
+
"@types/micromatch": "4.0.7",
|
|
108
|
+
"@types/node": "20.12.12",
|
|
105
109
|
"@types/react": "18.x",
|
|
106
|
-
"@types/rimraf": "^
|
|
110
|
+
"@types/rimraf": "^4.0.5",
|
|
107
111
|
"@types/semver": "latest",
|
|
108
112
|
"@types/yargs": "latest",
|
|
109
|
-
"@types/yargs-parser": "21.
|
|
110
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
111
|
-
"@typescript-eslint/parser": "^
|
|
112
|
-
"babel-jest": "^29.
|
|
113
|
-
"conventional-changelog-cli": "
|
|
113
|
+
"@types/yargs-parser": "21.0.3",
|
|
114
|
+
"@typescript-eslint/eslint-plugin": "^7.11.0",
|
|
115
|
+
"@typescript-eslint/parser": "^7.11.0",
|
|
116
|
+
"babel-jest": "^29.7.0",
|
|
117
|
+
"conventional-changelog-cli": "^5.0.0",
|
|
114
118
|
"cross-spawn": "latest",
|
|
115
|
-
"esbuild": "~0.
|
|
116
|
-
"eslint": "^8.
|
|
117
|
-
"eslint-config-prettier": "
|
|
118
|
-
"eslint-plugin-import": "
|
|
119
|
-
"eslint-plugin-jest": "
|
|
120
|
-
"eslint-plugin-jsdoc": "
|
|
121
|
-
"eslint-plugin-prefer-arrow": "
|
|
122
|
-
"eslint-plugin-prettier": "
|
|
119
|
+
"esbuild": "~0.21.4",
|
|
120
|
+
"eslint": "^8.57.0",
|
|
121
|
+
"eslint-config-prettier": "^9.1.0",
|
|
122
|
+
"eslint-plugin-import": "^2.29.1",
|
|
123
|
+
"eslint-plugin-jest": "^28.5.0",
|
|
124
|
+
"eslint-plugin-jsdoc": "^48.2.6",
|
|
125
|
+
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
126
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
123
127
|
"execa": "5.1.1",
|
|
124
|
-
"fs-extra": "11.
|
|
128
|
+
"fs-extra": "11.2.0",
|
|
125
129
|
"glob": "^10.2.6",
|
|
126
130
|
"glob-gitignore": "latest",
|
|
127
131
|
"husky": "4.x",
|
|
128
|
-
"jest": "^29.
|
|
132
|
+
"jest": "^29.7.0",
|
|
129
133
|
"jest-snapshot-serializer-raw": "^1.2.0",
|
|
130
134
|
"js-yaml": "latest",
|
|
131
|
-
"json-schema-to-typescript": "^13.
|
|
135
|
+
"json-schema-to-typescript": "^13.1.2",
|
|
132
136
|
"lint-staged": "latest",
|
|
133
137
|
"lodash.camelcase": "^4.3.0",
|
|
134
138
|
"lodash.set": "^4.3.2",
|
|
135
139
|
"node-fetch": "^3.3.2",
|
|
136
|
-
"prettier": "^2.
|
|
140
|
+
"prettier": "^3.2.5",
|
|
137
141
|
"typescript": "~5.1.3"
|
|
138
142
|
},
|
|
139
143
|
"lint-staged": {
|
|
@@ -143,6 +147,6 @@
|
|
|
143
147
|
]
|
|
144
148
|
},
|
|
145
149
|
"engines": {
|
|
146
|
-
"node": "^16.10.0 || ^18.0.0 || >=20.0.0"
|
|
150
|
+
"node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0"
|
|
147
151
|
}
|
|
148
152
|
}
|