ts-jest 29.1.0 → 29.1.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 CHANGED
@@ -1 +1 @@
1
- f6e34109d41dee339b6e88923445c043034af30a
1
+ fd7a2b389f3e20a065a96b71c5064b3e4ee76d33
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [29.1.2](https://github.com/kulshekhar/ts-jest/compare/v29.1.1...v29.1.2) (2024-01-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * calculated cache key based on `supportsStaticESM` ([a5d6f2d](https://github.com/kulshekhar/ts-jest/commit/a5d6f2d4f4bfa1c7c217f6faf9310958797b436f))
7
+ * correct error handling in `processAsync` ([e7be4bf](https://github.com/kulshekhar/ts-jest/commit/e7be4bf6a863cd76efec28f40fdd5193b2f50bad)), closes [#4207](https://github.com/kulshekhar/ts-jest/issues/4207)
8
+ * use `Config.ProjectConfig` ([918312b](https://github.com/kulshekhar/ts-jest/commit/918312bee22a795ec6bb347f95df4c1ff0a054de)), closes [#4028](https://github.com/kulshekhar/ts-jest/issues/4028)
9
+
10
+
11
+
12
+ ## [29.1.1](https://github.com/kulshekhar/ts-jest/compare/v29.1.0...v29.1.1) (2023-06-23)
13
+
14
+
15
+ ### Security Fixes
16
+
17
+ * bump `semver` to `7.5.3`
18
+
19
+
20
+
1
21
  # [29.1.0](https://github.com/kulshekhar/ts-jest/compare/v29.0.5...v29.1.0) (2023-03-26)
2
22
 
3
23
 
@@ -1,7 +1,7 @@
1
1
  import { Logger } from 'bs-logger';
2
2
  import type * as ts from 'typescript';
3
3
  import type { RawCompilerOptions } from '../../raw-compiler-options';
4
- import type { ProjectConfigTsJest, TsJestAstTransformer, TTypeScript } from '../../types';
4
+ import type { TsJestAstTransformer, TsJestTransformOptions, TTypeScript } from '../../types';
5
5
  export declare class ConfigSet {
6
6
  readonly parentLogger?: Logger | undefined;
7
7
  /**
@@ -18,7 +18,7 @@ export declare class ConfigSet {
18
18
  parsedTsConfig: ts.ParsedCommandLine | Record<string, any>;
19
19
  resolvedTransformers: TsJestAstTransformer;
20
20
  useESM: boolean;
21
- constructor(jestConfig: ProjectConfigTsJest | undefined, parentLogger?: Logger | undefined);
21
+ constructor(jestConfig: TsJestTransformOptions['config'] | undefined, parentLogger?: Logger | undefined);
22
22
  /**
23
23
  * Load TypeScript configuration. Returns the parsed TypeScript config and any `tsconfig` options specified in ts-jest
24
24
  * Subclasses which extend `ConfigSet` can override the default behavior
@@ -1,7 +1,7 @@
1
1
  import type { SyncTransformer, TransformedSource } from '@jest/transform';
2
- import type { CompilerInstance, ProjectConfigTsJest, TransformOptionsTsJest, TsJestGlobalOptions } from '../types';
2
+ import type { CompilerInstance, TsJestTransformerOptions, TsJestTransformOptions } from '../types';
3
3
  import { ConfigSet } from './config/config-set';
4
- export declare class TsJestTransformer implements SyncTransformer {
4
+ export declare class TsJestTransformer implements SyncTransformer<TsJestTransformerOptions> {
5
5
  private readonly tsJestConfig?;
6
6
  private readonly _logger;
7
7
  protected _compiler: CompilerInstance;
@@ -9,15 +9,15 @@ export declare class TsJestTransformer implements SyncTransformer {
9
9
  private _transformCfgStr;
10
10
  private _depGraphs;
11
11
  private _watchMode;
12
- constructor(tsJestConfig?: TsJestGlobalOptions | undefined);
12
+ constructor(tsJestConfig?: import("../types").TsJestGlobalOptions | undefined);
13
13
  private _configsFor;
14
- protected _createConfigSet(config: ProjectConfigTsJest | undefined): ConfigSet;
14
+ protected _createConfigSet(config: TsJestTransformOptions['config'] | undefined): ConfigSet;
15
15
  protected _createCompiler(configSet: ConfigSet, cacheFS: Map<string, string>): void;
16
16
  /**
17
17
  * @public
18
18
  */
19
- process(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): TransformedSource;
20
- processAsync(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): Promise<TransformedSource>;
19
+ process(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): TransformedSource;
20
+ processAsync(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): Promise<TransformedSource>;
21
21
  private processWithTs;
22
22
  private runTsJestHook;
23
23
  /**
@@ -27,8 +27,8 @@ export declare class TsJestTransformer implements SyncTransformer {
27
27
  *
28
28
  * @public
29
29
  */
30
- getCacheKey(fileContent: string, filePath: string, transformOptions: TransformOptionsTsJest): string;
31
- getCacheKeyAsync(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): Promise<string>;
30
+ getCacheKey(fileContent: string, filePath: string, transformOptions: TsJestTransformOptions): string;
31
+ getCacheKeyAsync(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): Promise<string>;
32
32
  /**
33
33
  * Subclasses extends `TsJestTransformer` can call this method to get resolved module disk cache
34
34
  */
@@ -196,40 +196,34 @@ var TsJestTransformer = exports.TsJestTransformer = /** @class */ (function () {
196
196
  return result;
197
197
  };
198
198
  TsJestTransformer.prototype.processAsync = function (sourceText, sourcePath, transformOptions) {
199
+ var _a;
199
200
  return __awaiter(this, void 0, void 0, function () {
200
- var _this = this;
201
- return __generator(this, function (_a) {
202
- this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
203
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
204
- var configs, shouldStringifyContent, babelJest, result, processWithTsResult;
205
- var _a;
206
- return __generator(this, function (_b) {
207
- switch (_b.label) {
208
- case 0:
209
- configs = this._configsFor(transformOptions);
210
- shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
211
- babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
212
- processWithTsResult = this.processWithTs(sourceText, sourcePath, transformOptions);
213
- result = {
214
- code: processWithTsResult.code,
215
- };
216
- if ((_a = processWithTsResult.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
217
- reject(configs.createTsError(processWithTsResult.diagnostics));
218
- }
219
- if (!babelJest) return [3 /*break*/, 2];
220
- this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
221
- return [4 /*yield*/, babelJest.processAsync(result.code, sourcePath, __assign(__assign({}, transformOptions), { instrument: false }))];
222
- case 1:
223
- // do not instrument here, jest will do it anyway afterwards
224
- result = _b.sent();
225
- _b.label = 2;
226
- case 2:
227
- result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
228
- resolve(result);
229
- return [2 /*return*/];
230
- }
231
- });
232
- }); })];
201
+ var configs, shouldStringifyContent, babelJest, result, processWithTsResult;
202
+ return __generator(this, function (_b) {
203
+ switch (_b.label) {
204
+ case 0:
205
+ this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
206
+ configs = this._configsFor(transformOptions);
207
+ shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
208
+ babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
209
+ processWithTsResult = this.processWithTs(sourceText, sourcePath, transformOptions);
210
+ result = {
211
+ code: processWithTsResult.code,
212
+ };
213
+ if ((_a = processWithTsResult.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
214
+ throw configs.createTsError(processWithTsResult.diagnostics);
215
+ }
216
+ if (!babelJest) return [3 /*break*/, 2];
217
+ this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
218
+ return [4 /*yield*/, babelJest.processAsync(result.code, sourcePath, __assign(__assign({}, transformOptions), { instrument: false }))];
219
+ case 1:
220
+ // do not instrument here, jest will do it anyway afterwards
221
+ result = _b.sent();
222
+ _b.label = 2;
223
+ case 2:
224
+ result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
225
+ return [2 /*return*/, result];
226
+ }
233
227
  });
234
228
  });
235
229
  };
@@ -311,7 +305,7 @@ var TsJestTransformer = exports.TsJestTransformer = /** @class */ (function () {
311
305
  var configs = this._configsFor(transformOptions);
312
306
  this._logger.debug({ fileName: filePath, transformOptions: transformOptions }, 'computing cache key for', filePath);
313
307
  // we do not instrument, ensure it is false all the time
314
- var instrument = (_a = transformOptions.instrument, _a === void 0 ? false : _a);
308
+ var supportsStaticESM = transformOptions.supportsStaticESM, instrument = (_a = transformOptions.instrument, _a === void 0 ? false : _a);
315
309
  var constructingCacheKeyElements = [
316
310
  this._transformCfgStr,
317
311
  exports.CACHE_KEY_EL_SEPARATOR,
@@ -319,6 +313,8 @@ var TsJestTransformer = exports.TsJestTransformer = /** @class */ (function () {
319
313
  exports.CACHE_KEY_EL_SEPARATOR,
320
314
  "instrument:".concat(instrument ? 'on' : 'off'),
321
315
  exports.CACHE_KEY_EL_SEPARATOR,
316
+ "supportsStaticESM:".concat(supportsStaticESM ? 'on' : 'off'),
317
+ exports.CACHE_KEY_EL_SEPARATOR,
322
318
  fileContent,
323
319
  exports.CACHE_KEY_EL_SEPARATOR,
324
320
  filePath,
package/dist/types.d.ts CHANGED
@@ -125,8 +125,8 @@ export interface ProjectConfigTsJest extends Config.ProjectConfig {
125
125
  /**
126
126
  * @deprecated use `JestConfigWithTsJest` instead
127
127
  */
128
- export interface TransformOptionsTsJest extends TransformOptions {
129
- config: ProjectConfigTsJest;
128
+ export interface TransformOptionsTsJest<TransformerConfig = unknown> extends TransformOptions<TransformerConfig> {
129
+ config: Config.ProjectConfig;
130
130
  }
131
131
  /**
132
132
  * For typings in `jest.config.ts`
@@ -142,6 +142,7 @@ export interface InitialOptionsTsJest extends Config.InitialOptions {
142
142
  globals?: GlobalConfigTsJest;
143
143
  }
144
144
  export type TsJestTransformerOptions = TsJestGlobalOptions;
145
+ export type TsJestTransformOptions = TransformOptions<TsJestTransformerOptions>;
145
146
  export interface JestConfigWithTsJest extends Omit<Config.InitialOptions, 'transform'> {
146
147
  transform?: {
147
148
  [regex: string]: 'ts-jest' | 'ts-jest/legacy' | ['ts-jest', TsJestTransformerOptions] | ['ts-jest/legacy', TsJestTransformerOptions] | string | Config.TransformerConfig;
@@ -41,4 +41,4 @@ exports.normalize = normalize;
41
41
  // eslint-disable-next-line @typescript-eslint/no-namespace
42
42
  (function (normalize) {
43
43
  normalize.cache = new Map();
44
- })(normalize = exports.normalize || (exports.normalize = {}));
44
+ })(normalize || (exports.normalize = normalize = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-jest",
3
- "version": "29.1.0",
3
+ "version": "29.1.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": {
@@ -57,7 +57,7 @@
57
57
  "json5": "^2.2.3",
58
58
  "lodash.memoize": "4.x",
59
59
  "make-error": "1.x",
60
- "semver": "7.x",
60
+ "semver": "^7.5.3",
61
61
  "yargs-parser": "^21.0.1"
62
62
  },
63
63
  "peerDependencies": {
@@ -90,7 +90,7 @@
90
90
  },
91
91
  "devDependencies": {
92
92
  "@commitlint/cli": "17.x",
93
- "@commitlint/config-angular": "^17.4.4",
93
+ "@commitlint/config-angular": "^17.6.5",
94
94
  "@jest/transform": "^29.5.0",
95
95
  "@jest/types": "^29.5.0",
96
96
  "@types/babel__core": "7.x",
@@ -101,19 +101,19 @@
101
101
  "@types/lodash.memoize": "4.x",
102
102
  "@types/lodash.set": "4.x",
103
103
  "@types/micromatch": "4.x",
104
- "@types/node": "18.15.11",
104
+ "@types/node": "18.16.18",
105
105
  "@types/react": "18.x",
106
106
  "@types/rimraf": "^3.0.2",
107
107
  "@types/semver": "latest",
108
108
  "@types/yargs": "latest",
109
109
  "@types/yargs-parser": "21.x",
110
- "@typescript-eslint/eslint-plugin": "^5.57.0",
111
- "@typescript-eslint/parser": "^5.57.0",
110
+ "@typescript-eslint/eslint-plugin": "^5.60.0",
111
+ "@typescript-eslint/parser": "^5.60.0",
112
112
  "babel-jest": "^29.5.0",
113
113
  "conventional-changelog-cli": "2.x",
114
114
  "cross-spawn": "latest",
115
- "esbuild": "~0.17.14",
116
- "eslint": "^8.37.0",
115
+ "esbuild": "~0.17.19",
116
+ "eslint": "^8.42.0",
117
117
  "eslint-config-prettier": "latest",
118
118
  "eslint-plugin-import": "latest",
119
119
  "eslint-plugin-jest": "latest",
@@ -122,19 +122,19 @@
122
122
  "eslint-plugin-prettier": "latest",
123
123
  "execa": "5.1.1",
124
124
  "fs-extra": "11.x",
125
- "glob": "^9.3.2",
125
+ "glob": "^10.2.6",
126
126
  "glob-gitignore": "latest",
127
127
  "husky": "4.x",
128
128
  "jest": "^29.5.0",
129
129
  "jest-snapshot-serializer-raw": "^1.2.0",
130
130
  "js-yaml": "latest",
131
- "json-schema-to-typescript": "^12.0.0",
131
+ "json-schema-to-typescript": "^13.0.2",
132
132
  "lint-staged": "latest",
133
133
  "lodash.camelcase": "^4.3.0",
134
134
  "lodash.set": "^4.3.2",
135
- "node-fetch": "^3.3.1",
136
- "prettier": "^2.8.7",
137
- "typescript": "~5.0.2"
135
+ "node-fetch": "^3.3.2",
136
+ "prettier": "^2.8.8",
137
+ "typescript": "~5.1.3"
138
138
  },
139
139
  "lint-staged": {
140
140
  "*.{ts,tsx,js,jsx}": [
@@ -143,6 +143,6 @@
143
143
  ]
144
144
  },
145
145
  "engines": {
146
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
146
+ "node": "^16.10.0 || ^18.0.0 || >=20.0.0"
147
147
  }
148
148
  }