ts-jest 29.3.2 → 29.3.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.
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var ts_jest_transformer_1 = require("./ts-jest-transformer");
3
+ const ts_jest_transformer_1 = require("./ts-jest-transformer");
4
4
  exports.default = {
5
- createTransformer: function (tsJestConfig) {
6
- return new ts_jest_transformer_1.TsJestTransformer(tsJestConfig);
7
- },
5
+ createTransformer: (tsJestConfig) => new ts_jest_transformer_1.TsJestTransformer(tsJestConfig),
8
6
  };
@@ -1,104 +1,42 @@
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __read = (this && this.__read) || function (o, n) {
50
- var m = typeof Symbol === "function" && o[Symbol.iterator];
51
- if (!m) return o;
52
- var i = m.call(o), r, ar = [], e;
53
- try {
54
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
- }
56
- catch (error) { e = { error: error }; }
57
- finally {
58
- try {
59
- if (r && !r.done && (m = i["return"])) m.call(i);
60
- }
61
- finally { if (e) throw e.error; }
62
- }
63
- return ar;
64
- };
65
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
- if (ar || !(i in from)) {
68
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
- ar[i] = from[i];
70
- }
71
- }
72
- return to.concat(ar || Array.prototype.slice.call(from));
73
- };
74
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
75
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
76
4
  };
77
5
  Object.defineProperty(exports, "__esModule", { value: true });
78
6
  exports.TsJestTransformer = exports.CACHE_KEY_EL_SEPARATOR = void 0;
79
- var fs_1 = require("fs");
80
- var path_1 = __importDefault(require("path"));
81
- var typescript_1 = __importDefault(require("typescript"));
82
- var constants_1 = require("../constants");
83
- var utils_1 = require("../utils");
84
- var importer_1 = require("../utils/importer");
85
- var messages_1 = require("../utils/messages");
86
- var sha1_1 = require("../utils/sha1");
87
- var compiler_1 = require("./compiler");
88
- var compiler_utils_1 = require("./compiler/compiler-utils");
89
- var config_set_1 = require("./config/config-set");
90
- var isNodeModule = function (filePath) {
7
+ const fs_1 = require("fs");
8
+ const path_1 = __importDefault(require("path"));
9
+ const typescript_1 = __importDefault(require("typescript"));
10
+ const constants_1 = require("../constants");
11
+ const utils_1 = require("../utils");
12
+ const importer_1 = require("../utils/importer");
13
+ const messages_1 = require("../utils/messages");
14
+ const sha1_1 = require("../utils/sha1");
15
+ const compiler_1 = require("./compiler");
16
+ const compiler_utils_1 = require("./compiler/compiler-utils");
17
+ const config_set_1 = require("./config/config-set");
18
+ const isNodeModule = (filePath) => {
91
19
  return path_1.default.normalize(filePath).split(path_1.default.sep).includes('node_modules');
92
20
  };
93
21
  /**
94
22
  * @internal
95
23
  */
96
24
  exports.CACHE_KEY_EL_SEPARATOR = '\x00';
97
- var TsJestTransformer = /** @class */ (function () {
98
- function TsJestTransformer(transformerOptions) {
25
+ class TsJestTransformer {
26
+ transformerOptions;
27
+ /**
28
+ * cache ConfigSet between test runs
29
+ *
30
+ * @internal
31
+ */
32
+ static _cachedConfigSets = [];
33
+ _logger;
34
+ _compiler;
35
+ _transformCfgStr;
36
+ _depGraphs = new Map();
37
+ _watchMode = false;
38
+ constructor(transformerOptions) {
99
39
  this.transformerOptions = transformerOptions;
100
- this._depGraphs = new Map();
101
- this._watchMode = false;
102
40
  this._logger = utils_1.rootLogger.child({ namespace: 'ts-jest-transformer' });
103
41
  /**
104
42
  * For some unknown reasons, `this` is undefined in `getCacheKey` and `process`
@@ -111,11 +49,10 @@ var TsJestTransformer = /** @class */ (function () {
111
49
  this._logger.debug('created new transformer');
112
50
  process.env.TS_JEST = '1';
113
51
  }
114
- TsJestTransformer.prototype._configsFor = function (transformOptions) {
115
- var _a, _b, _c;
116
- var config = transformOptions.config, cacheFS = transformOptions.cacheFS;
117
- var ccs = TsJestTransformer._cachedConfigSets.find(function (cs) { return cs.jestConfig.value === config; });
118
- var configSet;
52
+ _configsFor(transformOptions) {
53
+ const { config, cacheFS } = transformOptions;
54
+ const ccs = TsJestTransformer._cachedConfigSets.find((cs) => cs.jestConfig.value === config);
55
+ let configSet;
119
56
  if (ccs) {
120
57
  this._transformCfgStr = ccs.transformerCfgStr;
121
58
  this._compiler = ccs.compiler;
@@ -125,8 +62,8 @@ var TsJestTransformer = /** @class */ (function () {
125
62
  }
126
63
  else {
127
64
  // try to look-it up by stringified version
128
- var serializedJestCfg_1 = (0, utils_1.stringify)(config);
129
- var serializedCcs = TsJestTransformer._cachedConfigSets.find(function (cs) { return cs.jestConfig.serialized === serializedJestCfg_1; });
65
+ const serializedJestCfg = (0, utils_1.stringify)(config);
66
+ const serializedCcs = TsJestTransformer._cachedConfigSets.find((cs) => cs.jestConfig.serialized === serializedJestCfg);
130
67
  if (serializedCcs) {
131
68
  // update the object so that we can find it later
132
69
  // this happens because jest first calls getCacheKey with stringified version of
@@ -141,24 +78,34 @@ var TsJestTransformer = /** @class */ (function () {
141
78
  else {
142
79
  // create the new record in the index
143
80
  this._logger.info('no matching config-set found, creating a new one');
144
- if ((_a = config.globals) === null || _a === void 0 ? void 0 : _a['ts-jest']) {
81
+ if (config.globals?.['ts-jest']) {
145
82
  this._logger.warn("Define `ts-jest` config under `globals` is deprecated. Please do\ntransform: {\n <transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],\n},\nSee more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced" /* Deprecations.GlobalsTsJestConfigOption */);
146
83
  }
147
- var jestGlobalsConfig = (_b = config.globals) !== null && _b !== void 0 ? _b : {};
148
- var tsJestGlobalsConfig = (_c = jestGlobalsConfig['ts-jest']) !== null && _c !== void 0 ? _c : {};
149
- var migratedConfig = this.transformerOptions
150
- ? __assign(__assign({}, config), { globals: __assign(__assign({}, jestGlobalsConfig), { 'ts-jest': __assign(__assign({}, tsJestGlobalsConfig), this.transformerOptions) }) }) : config;
84
+ const jestGlobalsConfig = config.globals ?? {};
85
+ const tsJestGlobalsConfig = jestGlobalsConfig['ts-jest'] ?? {};
86
+ const migratedConfig = this.transformerOptions
87
+ ? {
88
+ ...config,
89
+ globals: {
90
+ ...jestGlobalsConfig,
91
+ 'ts-jest': {
92
+ ...tsJestGlobalsConfig,
93
+ ...this.transformerOptions,
94
+ },
95
+ },
96
+ }
97
+ : config;
151
98
  configSet = this._createConfigSet(migratedConfig);
152
- var jest_1 = __assign({}, migratedConfig);
99
+ const jest = { ...migratedConfig };
153
100
  // we need to remove some stuff from jest config
154
101
  // this which does not depend on config
155
- jest_1.cacheDirectory = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
156
- this._transformCfgStr = "".concat(new utils_1.JsonableValue(jest_1).serialized).concat(configSet.cacheSuffix);
102
+ jest.cacheDirectory = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
103
+ this._transformCfgStr = `${new utils_1.JsonableValue(jest).serialized}${configSet.cacheSuffix}`;
157
104
  this._createCompiler(configSet, cacheFS);
158
105
  this._watchMode = process.argv.includes('--watch');
159
106
  TsJestTransformer._cachedConfigSets.push({
160
107
  jestConfig: new utils_1.JsonableValue(config),
161
- configSet: configSet,
108
+ configSet,
162
109
  transformerCfgStr: this._transformCfgStr,
163
110
  compiler: this._compiler,
164
111
  depGraphs: this._depGraphs,
@@ -167,73 +114,68 @@ var TsJestTransformer = /** @class */ (function () {
167
114
  }
168
115
  }
169
116
  return configSet;
170
- };
171
- TsJestTransformer.prototype._createConfigSet = function (config) {
117
+ }
118
+ _createConfigSet(config) {
172
119
  return new config_set_1.ConfigSet(config);
173
- };
174
- TsJestTransformer.prototype._createCompiler = function (configSet, cacheFS) {
120
+ }
121
+ _createCompiler(configSet, cacheFS) {
175
122
  this._compiler = new compiler_1.TsJestCompiler(configSet, cacheFS);
176
- };
177
- TsJestTransformer.prototype.process = function (sourceText, sourcePath, transformOptions) {
178
- this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
179
- var configs = this._configsFor(transformOptions);
180
- var shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
181
- var babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
182
- var result = {
123
+ }
124
+ process(sourceText, sourcePath, transformOptions) {
125
+ this._logger.debug({ fileName: sourcePath, transformOptions }, 'processing', sourcePath);
126
+ const configs = this._configsFor(transformOptions);
127
+ const shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
128
+ const babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
129
+ let result = {
183
130
  code: this.processWithTs(sourceText, sourcePath, transformOptions).code,
184
131
  };
185
132
  if (babelJest) {
186
133
  this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
187
134
  // do not instrument here, jest will do it anyway afterwards
188
- result = babelJest.process(result.code, sourcePath, __assign(__assign({}, transformOptions), { instrument: false }));
135
+ result = babelJest.process(result.code, sourcePath, {
136
+ ...transformOptions,
137
+ instrument: false,
138
+ });
189
139
  }
190
140
  result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
191
141
  return result;
192
- };
193
- TsJestTransformer.prototype.processAsync = function (sourceText, sourcePath, transformOptions) {
194
- return __awaiter(this, void 0, void 0, function () {
195
- var configs, shouldStringifyContent, babelJest, result, processWithTsResult;
196
- var _a;
197
- return __generator(this, function (_b) {
198
- switch (_b.label) {
199
- case 0:
200
- this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
201
- configs = this._configsFor(transformOptions);
202
- shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
203
- babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
204
- processWithTsResult = this.processWithTs(sourceText, sourcePath, transformOptions);
205
- result = {
206
- code: processWithTsResult.code,
207
- };
208
- if ((_a = processWithTsResult.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
209
- throw configs.createTsError(processWithTsResult.diagnostics);
210
- }
211
- if (!babelJest) return [3 /*break*/, 2];
212
- this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
213
- return [4 /*yield*/, babelJest.processAsync(result.code, sourcePath, __assign(__assign({}, transformOptions), { instrument: false }))];
214
- case 1:
215
- // do not instrument here, jest will do it anyway afterwards
216
- result = _b.sent();
217
- _b.label = 2;
218
- case 2:
219
- result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
220
- return [2 /*return*/, result];
221
- }
142
+ }
143
+ async processAsync(sourceText, sourcePath, transformOptions) {
144
+ this._logger.debug({ fileName: sourcePath, transformOptions }, 'processing', sourcePath);
145
+ const configs = this._configsFor(transformOptions);
146
+ const shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
147
+ const babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
148
+ let result;
149
+ const processWithTsResult = this.processWithTs(sourceText, sourcePath, transformOptions);
150
+ result = {
151
+ code: processWithTsResult.code,
152
+ };
153
+ if (processWithTsResult.diagnostics?.length) {
154
+ throw configs.createTsError(processWithTsResult.diagnostics);
155
+ }
156
+ if (babelJest) {
157
+ this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
158
+ // do not instrument here, jest will do it anyway afterwards
159
+ result = await babelJest.processAsync(result.code, sourcePath, {
160
+ ...transformOptions,
161
+ instrument: false,
222
162
  });
223
- });
224
- };
225
- TsJestTransformer.prototype.processWithTs = function (sourceText, sourcePath, transformOptions) {
226
- var result;
227
- var configs = this._configsFor(transformOptions);
228
- var shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
229
- var babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
230
- var isDefinitionFile = sourcePath.endsWith(constants_1.DECLARATION_TYPE_EXT);
231
- var isJsFile = constants_1.JS_JSX_REGEX.test(sourcePath);
232
- var isTsFile = !isDefinitionFile && constants_1.TS_TSX_REGEX.test(sourcePath);
163
+ }
164
+ result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
165
+ return result;
166
+ }
167
+ processWithTs(sourceText, sourcePath, transformOptions) {
168
+ let result;
169
+ const configs = this._configsFor(transformOptions);
170
+ const shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
171
+ const babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
172
+ const isDefinitionFile = sourcePath.endsWith(constants_1.DECLARATION_TYPE_EXT);
173
+ const isJsFile = constants_1.JS_JSX_REGEX.test(sourcePath);
174
+ const isTsFile = !isDefinitionFile && constants_1.TS_TSX_REGEX.test(sourcePath);
233
175
  if (shouldStringifyContent) {
234
176
  // handles here what we should simply stringify
235
177
  result = {
236
- code: "module.exports=".concat((0, utils_1.stringify)(sourceText)),
178
+ code: `module.exports=${(0, utils_1.stringify)(sourceText)}`,
237
179
  };
238
180
  }
239
181
  else if (isDefinitionFile) {
@@ -244,10 +186,13 @@ var TsJestTransformer = /** @class */ (function () {
244
186
  }
245
187
  else if (isJsFile || isTsFile) {
246
188
  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
189
+ const transpiledResult = typescript_1.default.transpileModule(sourceText, {
190
+ compilerOptions: {
191
+ ...configs.parsedTsConfig.options,
192
+ module: transformOptions.supportsStaticESM && transformOptions.transformerConfig.useESM
249
193
  ? typescript_1.default.ModuleKind.ESNext
250
- : typescript_1.default.ModuleKind.CommonJS }),
194
+ : typescript_1.default.ModuleKind.CommonJS,
195
+ },
251
196
  fileName: sourcePath,
252
197
  });
253
198
  result = {
@@ -267,32 +212,32 @@ var TsJestTransformer = /** @class */ (function () {
267
212
  // we should not get called for files with other extension than js[x], ts[x] and d.ts,
268
213
  // TypeScript will bail if we try to compile, and if it was to call babel, users can
269
214
  // define the transform value with `babel-jest` for this extension instead
270
- var message = babelJest ? "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore. If you still want Babel to process it, add another entry to the `transform` option with value `babel-jest` which key matches this type of files." /* Errors.GotUnknownFileTypeWithBabel */ : "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore." /* Errors.GotUnknownFileTypeWithoutBabel */;
215
+ const message = babelJest ? "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore. If you still want Babel to process it, add another entry to the `transform` option with value `babel-jest` which key matches this type of files." /* Errors.GotUnknownFileTypeWithBabel */ : "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore." /* Errors.GotUnknownFileTypeWithoutBabel */;
271
216
  this._logger.warn({ fileName: sourcePath }, (0, messages_1.interpolate)(message, { path: sourcePath }));
272
217
  result = {
273
218
  code: sourceText,
274
219
  };
275
220
  }
276
221
  return result;
277
- };
278
- TsJestTransformer.prototype.runTsJestHook = function (sourcePath, sourceText, transformOptions, compiledOutput) {
279
- var hooksFile = process.env.TS_JEST_HOOKS;
280
- var hooks;
222
+ }
223
+ runTsJestHook(sourcePath, sourceText, transformOptions, compiledOutput) {
224
+ let hooksFile = process.env.TS_JEST_HOOKS;
225
+ let hooks;
281
226
  /* istanbul ignore next (cover by e2e) */
282
227
  if (hooksFile) {
283
228
  hooksFile = path_1.default.resolve(this._configsFor(transformOptions).cwd, hooksFile);
284
229
  hooks = importer_1.importer.tryTheseOr(hooksFile, {});
285
230
  }
286
231
  // This is not supposed to be a public API but we keep it as some people use it
287
- if (hooks === null || hooks === void 0 ? void 0 : hooks.afterProcess) {
232
+ if (hooks?.afterProcess) {
288
233
  this._logger.debug({ fileName: sourcePath, hookName: 'afterProcess' }, 'calling afterProcess hook');
289
- var newResult = hooks.afterProcess([sourceText, sourcePath, transformOptions.config, transformOptions], compiledOutput);
234
+ const newResult = hooks.afterProcess([sourceText, sourcePath, transformOptions.config, transformOptions], compiledOutput);
290
235
  if (newResult) {
291
236
  return newResult;
292
237
  }
293
238
  }
294
239
  return compiledOutput;
295
- };
240
+ }
296
241
  /**
297
242
  * Jest uses this to cache the compiled version of a file
298
243
  *
@@ -300,61 +245,49 @@ var TsJestTransformer = /** @class */ (function () {
300
245
  *
301
246
  * @public
302
247
  */
303
- TsJestTransformer.prototype.getCacheKey = function (fileContent, filePath, transformOptions) {
304
- var _a;
305
- var configs = this._configsFor(transformOptions);
306
- this._logger.debug({ fileName: filePath, transformOptions: transformOptions }, 'computing cache key for', filePath);
248
+ getCacheKey(fileContent, filePath, transformOptions) {
249
+ const configs = this._configsFor(transformOptions);
250
+ this._logger.debug({ fileName: filePath, transformOptions }, 'computing cache key for', filePath);
307
251
  // we do not instrument, ensure it is false all the time
308
- var supportsStaticESM = transformOptions.supportsStaticESM, _b = transformOptions.instrument, instrument = _b === void 0 ? false : _b;
309
- var constructingCacheKeyElements = [
252
+ const { supportsStaticESM, instrument = false } = transformOptions;
253
+ const constructingCacheKeyElements = [
310
254
  this._transformCfgStr,
311
255
  exports.CACHE_KEY_EL_SEPARATOR,
312
256
  configs.rootDir,
313
257
  exports.CACHE_KEY_EL_SEPARATOR,
314
- "instrument:".concat(instrument ? 'on' : 'off'),
258
+ `instrument:${instrument ? 'on' : 'off'}`,
315
259
  exports.CACHE_KEY_EL_SEPARATOR,
316
- "supportsStaticESM:".concat(supportsStaticESM ? 'on' : 'off'),
260
+ `supportsStaticESM:${supportsStaticESM ? 'on' : 'off'}`,
317
261
  exports.CACHE_KEY_EL_SEPARATOR,
318
262
  fileContent,
319
263
  exports.CACHE_KEY_EL_SEPARATOR,
320
264
  filePath,
321
265
  ];
322
266
  if (!configs.isolatedModules && configs.tsCacheDir) {
323
- var resolvedModuleNames = void 0;
324
- if (((_a = this._depGraphs.get(filePath)) === null || _a === void 0 ? void 0 : _a.fileContent) === fileContent) {
325
- this._logger.debug({ fileName: filePath, transformOptions: transformOptions }, 'getting resolved modules from disk caching or memory caching for', filePath);
267
+ let resolvedModuleNames;
268
+ if (this._depGraphs.get(filePath)?.fileContent === fileContent) {
269
+ this._logger.debug({ fileName: filePath, transformOptions }, 'getting resolved modules from disk caching or memory caching for', filePath);
326
270
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
327
271
  resolvedModuleNames = this._depGraphs
328
272
  .get(filePath)
329
- .resolvedModuleNames.filter(function (moduleName) { return (0, fs_1.existsSync)(moduleName); });
273
+ .resolvedModuleNames.filter((moduleName) => (0, fs_1.existsSync)(moduleName));
330
274
  }
331
275
  else {
332
- this._logger.debug({ fileName: filePath, transformOptions: transformOptions }, 'getting resolved modules from TypeScript API for', filePath);
276
+ this._logger.debug({ fileName: filePath, transformOptions }, 'getting resolved modules from TypeScript API for', filePath);
333
277
  resolvedModuleNames = this._compiler.getResolvedModules(fileContent, filePath, transformOptions.cacheFS);
334
278
  this._depGraphs.set(filePath, {
335
- fileContent: fileContent,
336
- resolvedModuleNames: resolvedModuleNames,
279
+ fileContent,
280
+ resolvedModuleNames,
337
281
  });
338
282
  }
339
- resolvedModuleNames.forEach(function (moduleName) {
283
+ resolvedModuleNames.forEach((moduleName) => {
340
284
  constructingCacheKeyElements.push(exports.CACHE_KEY_EL_SEPARATOR, moduleName, exports.CACHE_KEY_EL_SEPARATOR, (0, fs_1.statSync)(moduleName).mtimeMs.toString());
341
285
  });
342
286
  }
343
- return sha1_1.sha1.apply(void 0, __spreadArray([], __read(constructingCacheKeyElements), false));
344
- };
345
- TsJestTransformer.prototype.getCacheKeyAsync = function (sourceText, sourcePath, transformOptions) {
346
- return __awaiter(this, void 0, void 0, function () {
347
- return __generator(this, function (_a) {
348
- return [2 /*return*/, Promise.resolve(this.getCacheKey(sourceText, sourcePath, transformOptions))];
349
- });
350
- });
351
- };
352
- /**
353
- * cache ConfigSet between test runs
354
- *
355
- * @internal
356
- */
357
- TsJestTransformer._cachedConfigSets = [];
358
- return TsJestTransformer;
359
- }());
287
+ return (0, sha1_1.sha1)(...constructingCacheKeyElements);
288
+ }
289
+ async getCacheKeyAsync(sourceText, sourcePath, transformOptions) {
290
+ return Promise.resolve(this.getCacheKey(sourceText, sourcePath, transformOptions));
291
+ }
292
+ }
360
293
  exports.TsJestTransformer = TsJestTransformer;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var create_jest_preset_1 = require("./create-jest-preset");
4
- var allPresets = {
3
+ const create_jest_preset_1 = require("./create-jest-preset");
4
+ const allPresets = {
5
5
  get defaults() {
6
6
  return (0, create_jest_preset_1.createDefaultPreset)();
7
7
  },