ts-jest 26.4.1-alpha.0 → 26.4.3
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 +45 -0
- package/dist/compiler/instance.d.ts +2 -1
- package/dist/compiler/instance.js +6 -5
- package/dist/compiler/language-service.js +5 -15
- package/dist/compiler/transpiler.js +3 -3
- package/dist/config/config-set.d.ts +21 -7
- package/dist/config/config-set.js +287 -580
- package/dist/config/paths-to-module-name-mapper.d.ts +1 -1
- package/dist/config/paths-to-module-name-mapper.js +3 -3
- package/dist/constants.d.ts +4 -1
- package/dist/constants.js +2 -3
- package/dist/index.d.ts +2 -115
- package/dist/index.js +3 -54
- package/dist/ts-jest-transformer.d.ts +7 -7
- package/dist/ts-jest-transformer.js +48 -53
- package/dist/types.d.ts +7 -0
- package/dist/utils/json.d.ts +2 -1
- package/dist/utils/jsonable-value.d.ts +10 -1
- package/package.json +4 -3
- package/presets/index.js +20 -1
- package/utils/index.d.ts +3 -1
- package/utils/index.js +15 -1
- package/dist/presets/index.d.ts +0 -339
- package/dist/presets/index.js +0 -18
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -9
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
8d5136276832f00420aff1da4906f548e3690021
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
## [26.4.3](https://github.com/kulshekhar/ts-jest/compare/v26.4.2...v26.4.3) (2020-10-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **compiler:** only exclude test files when initializing compiler ([#2062](https://github.com/kulshekhar/ts-jest/issues/2062)) ([7264c13](https://github.com/kulshekhar/ts-jest/commit/7264c137114b6dd895624e3476dd7ec57b64ee13)), closes [#2061](https://github.com/kulshekhar/ts-jest/issues/2061), [#2068](https://github.com/kulshekhar/ts-jest/issues/2068), [#2072](https://github.com/kulshekhar/ts-jest/issues/2072), [#2073](https://github.com/kulshekhar/ts-jest/issues/2073)
|
|
7
|
+
* **config:** resolve `.babelrc` file path before attempting to read it ([#2071](https://github.com/kulshekhar/ts-jest/issues/2071)) ([681bfef](https://github.com/kulshekhar/ts-jest/commit/681bfef41744f09cd50b71072f4d001cb58da82e)), closes [#2064](https://github.com/kulshekhar/ts-jest/issues/2064)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **config:** allow to override resolve tsconfig behavior ([#2063](https://github.com/kulshekhar/ts-jest/issues/2063)) ([9f46ace](https://github.com/kulshekhar/ts-jest/commit/9f46acefceb1fa71ee2e8b3b3c172ceb0544b4c4))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [26.4.2](https://github.com/kulshekhar/ts-jest/compare/v26.4.1...v26.4.2) (2020-10-23)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* **config:** expose several typings as public apis ([#2054](https://github.com/kulshekhar/ts-jest/issues/2054)) ([3b6b705](https://github.com/kulshekhar/ts-jest/commit/3b6b7055e2b9c74e81fb91596c807ace02ab77a1))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Performance Improvements
|
|
25
|
+
|
|
26
|
+
* **compiler:** speed up bootstrap time for `isolatedModules:false` ([#2055](https://github.com/kulshekhar/ts-jest/issues/2055)) ([230b5dd](https://github.com/kulshekhar/ts-jest/commit/230b5ddbee55357d25dd190cd45aa8a30d7f31e0))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### DEPRECATIONS
|
|
30
|
+
|
|
31
|
+
* **config**: deprecate `tsConfig` in favor of `tsconfig` ([#1997](https://github.com/kulshekhar/ts-jest/pull/1997))
|
|
32
|
+
* **config**: deprecate `packageJson` since internal codes don't use it anymore ([#2034](https://github.com/kulshekhar/ts-jest/pull/2034))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [26.4.1](https://github.com/kulshekhar/ts-jest/compare/v26.4.0...v26.4.1) (2020-09-29)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* **utils:** `MaybeMockedConstructor` returns T ([#1976](https://github.com/kulshekhar/ts-jest/issues/1976)) ([b7712b2](https://github.com/kulshekhar/ts-jest/commit/b7712b2055d8f32dd97999de1d94e8f3515d79e8))
|
|
42
|
+
* **utils:** revert `path.join` and add check on prefix ends with `/` ([#1989](https://github.com/kulshekhar/ts-jest/issues/1989)) ([3d9035b](https://github.com/kulshekhar/ts-jest/commit/3d9035bd70dc087d4c5a943bb2fe2af2d0822875)), closes [#1982](https://github.com/kulshekhar/ts-jest/issues/1982)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
1
46
|
# [26.4.0](https://github.com/kulshekhar/ts-jest/compare/v26.3.0...v26.4.0) (2020-09-20)
|
|
2
47
|
|
|
3
48
|
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const SOURCE_MAPPING_PREFIX = "sourceMappingURL=";
|
|
2
|
+
export declare function updateOutput(outputText: string, normalizedFileName: string, sourceMap: string): string;
|
|
@@ -16,16 +16,17 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.createCompilerInstance = void 0;
|
|
19
|
+
exports.createCompilerInstance = exports.updateOutput = exports.SOURCE_MAPPING_PREFIX = void 0;
|
|
20
20
|
var language_service_1 = require("./language-service");
|
|
21
21
|
var transpiler_1 = require("./transpiler");
|
|
22
22
|
var json_1 = require("../utils/json");
|
|
23
|
-
|
|
23
|
+
exports.SOURCE_MAPPING_PREFIX = 'sourceMappingURL=';
|
|
24
24
|
function updateOutput(outputText, normalizedFileName, sourceMap) {
|
|
25
25
|
var base64Map = Buffer.from(updateSourceMap(sourceMap, normalizedFileName), 'utf8').toString('base64');
|
|
26
26
|
var sourceMapContent = "data:application/json;charset=utf-8;base64," + base64Map;
|
|
27
|
-
return (outputText.slice(0, outputText.lastIndexOf(SOURCE_MAPPING_PREFIX) + SOURCE_MAPPING_PREFIX.length) + sourceMapContent);
|
|
27
|
+
return (outputText.slice(0, outputText.lastIndexOf(exports.SOURCE_MAPPING_PREFIX) + exports.SOURCE_MAPPING_PREFIX.length) + sourceMapContent);
|
|
28
28
|
}
|
|
29
|
+
exports.updateOutput = updateOutput;
|
|
29
30
|
var updateSourceMap = function (sourceMapText, normalizedFileName) {
|
|
30
31
|
var sourceMap = JSON.parse(sourceMapText);
|
|
31
32
|
sourceMap.file = normalizedFileName;
|
|
@@ -40,13 +41,13 @@ var compileAndUpdateOutput = function (compileFn, logger) { return function (cod
|
|
|
40
41
|
}; };
|
|
41
42
|
exports.createCompilerInstance = function (configs) {
|
|
42
43
|
var logger = configs.logger.child({ namespace: 'ts-compiler' });
|
|
43
|
-
var compilerOptions = configs.parsedTsConfig.options
|
|
44
|
+
var compilerOptions = configs.parsedTsConfig.options;
|
|
44
45
|
var extensions = ['.ts', '.tsx'];
|
|
45
46
|
if (compilerOptions.allowJs) {
|
|
46
47
|
extensions.push('.js');
|
|
47
48
|
extensions.push('.jsx');
|
|
48
49
|
}
|
|
49
|
-
var compilerInstance = !
|
|
50
|
+
var compilerInstance = !configs.isolatedModules
|
|
50
51
|
? language_service_1.initializeLanguageServiceInstance(configs, logger)
|
|
51
52
|
: transpiler_1.initializeTranspilerInstance(configs, logger);
|
|
52
53
|
var compile = compileAndUpdateOutput(compilerInstance.compileFn, logger);
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -89,7 +78,7 @@ var messages_1 = require("../utils/messages");
|
|
|
89
78
|
var json_1 = require("../utils/json");
|
|
90
79
|
var sha1_1 = require("../utils/sha1");
|
|
91
80
|
function doTypeChecking(configs, diagnosedFiles, fileName, service, logger) {
|
|
92
|
-
if (configs.
|
|
81
|
+
if (configs.shouldReportDiagnostics(fileName)) {
|
|
93
82
|
var diagnostics = service.getSemanticDiagnostics(fileName).concat(service.getSyntacticDiagnostics(fileName));
|
|
94
83
|
diagnosedFiles.push(fileName);
|
|
95
84
|
configs.raiseDiagnostics(diagnostics, fileName, logger);
|
|
@@ -123,7 +112,9 @@ exports.initializeLanguageServiceInstance = function (configs, logger) {
|
|
|
123
112
|
}
|
|
124
113
|
catch (e) { }
|
|
125
114
|
}
|
|
126
|
-
configs.parsedTsConfig.fileNames
|
|
115
|
+
configs.parsedTsConfig.fileNames
|
|
116
|
+
.filter(function (fileName) { return !configs.isTestFile(fileName); })
|
|
117
|
+
.forEach(function (fileName) {
|
|
127
118
|
memoryCache.files.set(fileName, {
|
|
128
119
|
version: 0,
|
|
129
120
|
});
|
|
@@ -222,7 +213,7 @@ exports.initializeLanguageServiceInstance = function (configs, logger) {
|
|
|
222
213
|
getCurrentDirectory: function () { return cwd; },
|
|
223
214
|
getCompilationSettings: function () { return options; },
|
|
224
215
|
getDefaultLibFileName: function () { return ts.getDefaultLibFilePath(options); },
|
|
225
|
-
getCustomTransformers: function () { return configs.
|
|
216
|
+
getCustomTransformers: function () { return configs.customTransformers; },
|
|
226
217
|
resolveModuleNames: resolveModuleNames,
|
|
227
218
|
};
|
|
228
219
|
logger.debug('initializeLanguageServiceInstance(): creating language service');
|
|
@@ -282,7 +273,6 @@ exports.initializeLanguageServiceInstance = function (configs, logger) {
|
|
|
282
273
|
file: path_1.basename(fileName),
|
|
283
274
|
}));
|
|
284
275
|
}
|
|
285
|
-
memoryCache.files.set(fileName, __assign(__assign({}, memoryCache.files.get(fileName)), { output: output.outputFiles[1].text }));
|
|
286
276
|
return [output.outputFiles[1].text, output.outputFiles[0].text];
|
|
287
277
|
},
|
|
288
278
|
program: service.getProgram(),
|
|
@@ -10,11 +10,11 @@ exports.initializeTranspilerInstance = function (configs, logger) {
|
|
|
10
10
|
logger.debug({ fileName: fileName }, 'compileFn(): compiling as isolated module');
|
|
11
11
|
var result = ts.transpileModule(code, {
|
|
12
12
|
fileName: fileName,
|
|
13
|
-
transformers: configs.
|
|
13
|
+
transformers: configs.customTransformers,
|
|
14
14
|
compilerOptions: options,
|
|
15
|
-
reportDiagnostics: configs.
|
|
15
|
+
reportDiagnostics: configs.shouldReportDiagnostics(fileName),
|
|
16
16
|
});
|
|
17
|
-
if (result.diagnostics && configs.
|
|
17
|
+
if (result.diagnostics && configs.shouldReportDiagnostics(fileName)) {
|
|
18
18
|
configs.raiseDiagnostics(result.diagnostics, fileName, logger);
|
|
19
19
|
}
|
|
20
20
|
return [result.outputText, result.sourceMapText];
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import type { Config } from '@jest/types';
|
|
2
2
|
import { Logger } from 'bs-logger';
|
|
3
|
-
import
|
|
3
|
+
import { CompilerOptions, CustomTransformers, Diagnostic, ParsedCommandLine } from 'typescript';
|
|
4
|
+
import type { TTypeScript } from '../types';
|
|
4
5
|
export declare class ConfigSet {
|
|
5
|
-
readonly parentOptions?: TsJestGlobalOptions | undefined;
|
|
6
|
-
get versions(): Record<string, string>;
|
|
7
|
-
get compilerModule(): TTypeScript;
|
|
8
|
-
get tsCompiler(): TsCompiler;
|
|
9
|
-
get tsJestDigest(): string;
|
|
10
6
|
readonly logger: Logger;
|
|
11
|
-
|
|
7
|
+
readonly compilerModule: TTypeScript;
|
|
8
|
+
readonly isolatedModules: boolean;
|
|
9
|
+
readonly cwd: string;
|
|
10
|
+
tsCacheDir: string | undefined;
|
|
11
|
+
parsedTsConfig: ParsedCommandLine | Record<string, any>;
|
|
12
|
+
customTransformers: CustomTransformers;
|
|
13
|
+
readonly rootDir: string;
|
|
14
|
+
protected _overriddenCompilerOptions: Partial<CompilerOptions>;
|
|
15
|
+
constructor(jestConfig: Config.ProjectConfig, parentLogger?: Logger | undefined);
|
|
16
|
+
protected _resolveTsConfig(compilerOptions?: CompilerOptions, resolvedConfigFile?: string): Record<string, any>;
|
|
17
|
+
get tsJestDigest(): string;
|
|
18
|
+
get isTestFile(): (fileName: string) => boolean;
|
|
19
|
+
shouldStringifyContent(filePath: string): boolean;
|
|
20
|
+
raiseDiagnostics(diagnostics: Diagnostic[], filePath?: string, logger?: Logger): void;
|
|
21
|
+
shouldReportDiagnostics(filePath: string): boolean;
|
|
22
|
+
resolvePath(inputPath: string, { throwIfMissing, nodeResolve }?: {
|
|
23
|
+
throwIfMissing?: boolean;
|
|
24
|
+
nodeResolve?: boolean;
|
|
25
|
+
}): string;
|
|
12
26
|
}
|