ts-jest 27.1.0 → 27.1.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/README.md +1 -1
- package/dist/config/config-set.d.ts +3 -3
- package/dist/config/config-set.js +3 -2
- package/dist/ts-jest-transformer.js +14 -0
- package/dist/types.d.ts +2 -0
- package/dist/utils/importer.js +3 -0
- package/package.json +11 -7
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
89e23259863a0cf11a2b03a32d700d94c8b151b2
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [27.1.1](https://github.com/kulshekhar/ts-jest/compare/v27.1.0...v27.1.1) (2021-12-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bring back `afterProcess` hook ([#3132](https://github.com/kulshekhar/ts-jest/issues/3132)) ([2b6b86e](https://github.com/kulshekhar/ts-jest/commit/2b6b86e01dcd3d9d9906f24fe3db5cadb799146a))
|
|
7
|
+
* make `esbuild` as optional peer dependency ([#3129](https://github.com/kulshekhar/ts-jest/issues/3129)) ([20258de](https://github.com/kulshekhar/ts-jest/commit/20258de54c9c10f8d2495bda174f9865a3cebc91))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
1
11
|
# [27.1.0](https://github.com/kulshekhar/ts-jest/compare/v27.0.7...v27.1.0) (2021-11-30)
|
|
2
12
|
|
|
3
13
|
|
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduc
|
|
|
53
53
|
|
|
54
54
|
## Versioning
|
|
55
55
|
|
|
56
|
-
We **DO NOT** use [SemVer](
|
|
56
|
+
We **DO NOT** use [SemVer](https://semver.org/) for versioning. Though you can think about SemVer when reading our version, except our major number follows the one of Jest. For the versions available, see the [tags on this repository](https://github.com/kulshekhar/ts-jest/tags).
|
|
57
57
|
|
|
58
58
|
## Authors/maintainers
|
|
59
59
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from 'bs-logger';
|
|
2
|
-
import type
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
3
|
import type { RawCompilerOptions } from '../raw-compiler-options';
|
|
4
4
|
import type { ProjectConfigTsJest, TsJestAstTransformer, TTypeScript } from '../types';
|
|
5
5
|
export declare class ConfigSet {
|
|
@@ -12,14 +12,14 @@ export declare class ConfigSet {
|
|
|
12
12
|
readonly rootDir: string;
|
|
13
13
|
cacheSuffix: string;
|
|
14
14
|
tsCacheDir: string | undefined;
|
|
15
|
-
parsedTsConfig: ParsedCommandLine | Record<string, any>;
|
|
15
|
+
parsedTsConfig: ts.ParsedCommandLine | Record<string, any>;
|
|
16
16
|
resolvedTransformers: TsJestAstTransformer;
|
|
17
17
|
useESM: boolean;
|
|
18
18
|
constructor(jestConfig: ProjectConfigTsJest | undefined, parentLogger?: Logger | undefined);
|
|
19
19
|
protected _resolveTsConfig(compilerOptions?: RawCompilerOptions, resolvedConfigFile?: string): Record<string, any>;
|
|
20
20
|
isTestFile(fileName: string): boolean;
|
|
21
21
|
shouldStringifyContent(filePath: string): boolean;
|
|
22
|
-
raiseDiagnostics(diagnostics: Diagnostic[], filePath?: string, logger?: Logger): void;
|
|
22
|
+
raiseDiagnostics(diagnostics: ts.Diagnostic[], filePath?: string, logger?: Logger): void;
|
|
23
23
|
shouldReportDiagnostics(filePath: string): boolean;
|
|
24
24
|
resolvePath(inputPath: string, { throwIfMissing, nodeResolve }?: {
|
|
25
25
|
throwIfMissing?: boolean;
|
|
@@ -55,7 +55,6 @@ var fs_1 = require("fs");
|
|
|
55
55
|
var module_1 = __importDefault(require("module"));
|
|
56
56
|
var path_1 = require("path");
|
|
57
57
|
var bs_logger_1 = require("bs-logger");
|
|
58
|
-
var esbuild_1 = require("esbuild");
|
|
59
58
|
var jest_util_1 = require("jest-util");
|
|
60
59
|
var json5_1 = __importDefault(require("json5"));
|
|
61
60
|
var constants_1 = require("../constants");
|
|
@@ -238,7 +237,9 @@ var ConfigSet = (function () {
|
|
|
238
237
|
var resolveTransformerFunc_1 = function (transformerPath) {
|
|
239
238
|
var transformerFunc;
|
|
240
239
|
if ((0, path_1.extname)(transformerPath) === '.ts') {
|
|
241
|
-
var compiledTransformer =
|
|
240
|
+
var compiledTransformer = importer_1.importer
|
|
241
|
+
.esBuild("Using \"esbuild\" requires this package to be installed.")
|
|
242
|
+
.transformSync((0, fs_1.readFileSync)(transformerPath, 'utf-8'), {
|
|
242
243
|
loader: 'ts',
|
|
243
244
|
format: 'cjs',
|
|
244
245
|
target: 'es2015',
|
|
@@ -82,6 +82,7 @@ var compiler_1 = require("./compiler");
|
|
|
82
82
|
var config_1 = require("./config");
|
|
83
83
|
var constants_1 = require("./constants");
|
|
84
84
|
var utils_1 = require("./utils");
|
|
85
|
+
var importer_1 = require("./utils/importer");
|
|
85
86
|
var messages_1 = require("./utils/messages");
|
|
86
87
|
var sha1_1 = require("./utils/sha1");
|
|
87
88
|
var version_checkers_1 = require("./utils/version-checkers");
|
|
@@ -161,6 +162,12 @@ var TsJestTransformer = (function () {
|
|
|
161
162
|
var isDefinitionFile = filePath.endsWith(constants_1.DECLARATION_TYPE_EXT);
|
|
162
163
|
var isJsFile = constants_1.JS_JSX_REGEX.test(filePath);
|
|
163
164
|
var isTsFile = !isDefinitionFile && constants_1.TS_TSX_REGEX.test(filePath);
|
|
165
|
+
var hooksFile = process.env.TS_JEST_HOOKS;
|
|
166
|
+
var hooks;
|
|
167
|
+
if (hooksFile) {
|
|
168
|
+
hooksFile = path_1.default.resolve(configs.cwd, hooksFile);
|
|
169
|
+
hooks = importer_1.importer.tryTheseOr(hooksFile, {});
|
|
170
|
+
}
|
|
164
171
|
if (shouldStringifyContent) {
|
|
165
172
|
result = "module.exports=".concat((0, utils_1.stringify)(fileContent));
|
|
166
173
|
}
|
|
@@ -187,6 +194,13 @@ var TsJestTransformer = (function () {
|
|
|
187
194
|
this._logger.debug({ fileName: filePath }, 'calling babel-jest processor');
|
|
188
195
|
result = babelJest.process(result, filePath, __assign(__assign({}, transformOptions), { instrument: false }));
|
|
189
196
|
}
|
|
197
|
+
if (hooks === null || hooks === void 0 ? void 0 : hooks.afterProcess) {
|
|
198
|
+
this._logger.debug({ fileName: filePath, hookName: 'afterProcess' }, 'calling afterProcess hook');
|
|
199
|
+
var newResult = hooks.afterProcess([fileContent, filePath, transformOptions.config, transformOptions], result);
|
|
200
|
+
if (newResult) {
|
|
201
|
+
return newResult;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
190
204
|
return result;
|
|
191
205
|
};
|
|
192
206
|
TsJestTransformer.prototype.processAsync = function (sourceText, sourcePath, transformOptions) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TransformOptions } from '@jest/transform';
|
|
2
2
|
import type { Config } from '@jest/types';
|
|
3
3
|
import type * as _babel from 'babel__core';
|
|
4
|
+
import type * as _esbuild from 'esbuild';
|
|
4
5
|
import type * as _ts from 'typescript';
|
|
5
6
|
import type { ConfigSet } from './config';
|
|
6
7
|
import type { RawCompilerOptions } from './raw-compiler-options';
|
|
@@ -12,6 +13,7 @@ declare module '@jest/types' {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
export declare type TTypeScript = typeof _ts;
|
|
16
|
+
export declare type TEsBuild = typeof _esbuild;
|
|
15
17
|
export declare type BabelConfig = _babel.TransformOptions;
|
|
16
18
|
export declare type TsJestPresets = Pick<Config.InitialOptions, 'extensionsToTreatAsEsm' | 'moduleFileExtensions' | 'transform' | 'testMatch'>;
|
|
17
19
|
export interface AstTransformer<T = Record<string, unknown>> {
|
package/dist/utils/importer.js
CHANGED
|
@@ -79,6 +79,9 @@ var Importer = (function () {
|
|
|
79
79
|
Importer.prototype.typescript = function (why, which) {
|
|
80
80
|
return this._import(why, which);
|
|
81
81
|
};
|
|
82
|
+
Importer.prototype.esBuild = function (why) {
|
|
83
|
+
return this._import(why, 'esbuild');
|
|
84
|
+
};
|
|
82
85
|
Importer.prototype.tryThese = function (moduleName) {
|
|
83
86
|
var fallbacks = [];
|
|
84
87
|
for (var _i = 1; _i < arguments.length; _i++) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "27.1.
|
|
3
|
+
"version": "27.1.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"homepage": "https://kulshekhar.github.io/ts-jest",
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"bs-logger": "0.x",
|
|
55
|
-
"esbuild": "~0.14.0",
|
|
56
55
|
"fast-json-stable-stringify": "2.x",
|
|
57
56
|
"jest-util": "^27.0.0",
|
|
58
57
|
"json5": "2.x",
|
|
@@ -65,18 +64,22 @@
|
|
|
65
64
|
"@babel/core": ">=7.0.0-beta.0 <8",
|
|
66
65
|
"@types/jest": "^27.0.0",
|
|
67
66
|
"babel-jest": ">=27.0.0 <28",
|
|
67
|
+
"esbuild": "~0.14.0",
|
|
68
68
|
"jest": "^27.0.0",
|
|
69
69
|
"typescript": ">=3.8 <5.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependenciesMeta": {
|
|
72
|
-
"babel-jest": {
|
|
73
|
-
"optional": true
|
|
74
|
-
},
|
|
75
72
|
"@babel/core": {
|
|
76
73
|
"optional": true
|
|
77
74
|
},
|
|
78
75
|
"@types/jest": {
|
|
79
76
|
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"babel-jest": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"esbuild": {
|
|
82
|
+
"optional": true
|
|
80
83
|
}
|
|
81
84
|
},
|
|
82
85
|
"husky": {
|
|
@@ -100,7 +103,7 @@
|
|
|
100
103
|
"@types/lodash.memoize": "4.x",
|
|
101
104
|
"@types/lodash.set": "4.x",
|
|
102
105
|
"@types/micromatch": "4.x",
|
|
103
|
-
"@types/node": "16.11.
|
|
106
|
+
"@types/node": "16.11.12",
|
|
104
107
|
"@types/node-fetch": "^3.0.3",
|
|
105
108
|
"@types/react": "17.x",
|
|
106
109
|
"@types/rimraf": "^3.0.2",
|
|
@@ -111,7 +114,8 @@
|
|
|
111
114
|
"@typescript-eslint/parser": "^5.3.0",
|
|
112
115
|
"conventional-changelog-cli": "2.x",
|
|
113
116
|
"cross-spawn": "latest",
|
|
114
|
-
"
|
|
117
|
+
"esbuild": "~0.14.2",
|
|
118
|
+
"eslint": "8.4.1",
|
|
115
119
|
"eslint-config-prettier": "latest",
|
|
116
120
|
"eslint-plugin-import": "latest",
|
|
117
121
|
"eslint-plugin-jest": "latest",
|