🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

ts-jest

Package Overview
Dependencies
Maintainers
3
Versions
203
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-jest - npm Package Compare versions

Comparing version

to
29.3.1

3

dist/legacy/compiler/ts-compiler.d.ts
import { Logger } from 'bs-logger';
import { CompilerOptions, CustomTransformers, Program, TranspileOutput } from 'typescript';
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript } from '../../types';
import { CompiledOutput } from '../../types';
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript, CompiledOutput } from '../../types';
import type { ConfigSet } from '../config/config-set';

@@ -6,0 +5,0 @@ export declare class TsCompiler implements TsCompilerInstance {

@@ -59,3 +59,2 @@ "use strict";

var constants_1 = require("../../constants");
// import { tsTranspileModule } from '../../transpilers/typescript/transpile-module'
var transpile_module_1 = require("../../transpilers/typescript/transpile-module");

@@ -65,12 +64,2 @@ var utils_1 = require("../../utils");

var compiler_utils_1 = require("./compiler-utils");
var isModernNodeResolution = function (module) {
return module ? [typescript_1.default.ModuleKind.Node16, /* ModuleKind.Node18 */ 101, typescript_1.default.ModuleKind.NodeNext].includes(module) : false;
};
var shouldUseNativeTsTranspile = function (compilerOptions) {
if (!compilerOptions) {
return true;
}
var module = compilerOptions.module;
return !isModernNodeResolution(module);
};
var assertCompilerOptionsWithJestTransformMode = function (compilerOptions, isEsmMode, logger) {

@@ -147,3 +136,3 @@ if (isEsmMode && compilerOptions.module === typescript_1.default.ModuleKind.CommonJS) {

var esModuleInterop = compilerOptions.esModuleInterop;
if (isModernNodeResolution(moduleKind)) {
if ((0, transpile_module_1.isModernNodeModuleKind)(moduleKind)) {
esModuleInterop = true;

@@ -162,3 +151,3 @@ moduleKind = this._ts.ModuleKind.ESNext;

this._compilerOptions = this.fixupCompilerOptionsForModuleKind(this._initialCompilerOptions, isEsmMode);
if (!this._initialCompilerOptions.isolatedModules && isModernNodeResolution(this._initialCompilerOptions.module)) {
if (!this._initialCompilerOptions.isolatedModules && (0, transpile_module_1.isModernNodeModuleKind)(this._initialCompilerOptions.module)) {
this._logger.warn("Using hybrid module kind (Node16/18/Next) is only supported in \"isolatedModules: true\". Please set \"isolatedModules: true\" in your tsconfig.json." /* Helps.UsingModernNodeResolution */);

@@ -242,3 +231,9 @@ }

TsCompiler.prototype._transpileOutput = function (fileContent, fileName) {
if (shouldUseNativeTsTranspile(this._initialCompilerOptions)) {
var _this = this;
/**
* @deprecated
*
* This code path should be removed in the next major version to benefit from checking on compiler options
*/
if (!(0, transpile_module_1.isModernNodeModuleKind)(this._initialCompilerOptions.module)) {
return this._ts.transpileModule(fileContent, {

@@ -253,3 +248,6 @@ fileName: fileName,

fileName: fileName,
transformers: this._makeTransformers(this.configSet.resolvedTransformers),
transformers: function (program) {
_this.program = program;
return _this._makeTransformers(_this.configSet.resolvedTransformers);
},
compilerOptions: this._initialCompilerOptions,

@@ -256,0 +254,0 @@ reportDiagnostics: fileName ? this.configSet.shouldReportDiagnostics(fileName) : false,

@@ -228,3 +228,3 @@ "use strict";

if (this.tsconfigFilePath) {
this.logger.warn((0, messages_1.interpolate)("\"isolatedModules\" is deprecated and will be removed in v30.0.0. Please remove \"isolatedModules\" from your \"ts-jest\" transform options and enable \"isolatedModules: true\" in {{tsconfigFilePath}} instead." /* Deprecations.IsolatedModulesWithTsconfigPath */, {
this.logger.warn((0, messages_1.interpolate)("\n The \"ts-jest\" config option \"isolatedModules\" is deprecated and will be removed in v30.0.0. Please use \"isolatedModules: true\" in {{tsconfigFilePath}} instead, see https://www.typescriptlang.org/tsconfig/#isolatedModules\n " /* Deprecations.IsolatedModulesWithTsconfigPath */, {
tsconfigFilePath: this.tsconfigFilePath,

@@ -234,3 +234,3 @@ }));

else {
this.logger.warn("\"isolatedModules\" is deprecated and will be removed in v30.0.0. Please remove \"isolatedModules\" from your \"ts-jest\" transform options and enable \"isolatedModules: true\" in a tsconfig file instead." /* Deprecations.IsolatedModulesWithoutTsconfigPath */);
this.logger.warn("\n The \"ts-jest\" config option \"isolatedModules\" is deprecated and will be removed in v30.0.0. Please use \"isolatedModules: true\", see https://www.typescriptlang.org/tsconfig/#isolatedModules\n " /* Deprecations.IsolatedModulesWithoutTsconfigPath */);
}

@@ -237,0 +237,0 @@ }

import ts from 'typescript';
type ExtendedTsTranspileModuleFn = (input: string, transpileOptions: ts.TranspileOptions) => ts.TranspileOutput;
type ExtendedTranspileOptions = Omit<ts.TranspileOptions, 'transformers'> & {
transformers?: (program: ts.Program) => ts.CustomTransformers;
};
type ExtendedTsTranspileModuleFn = (fileContent: string, transpileOptions: ExtendedTranspileOptions) => ts.TranspileOutput;
export declare const isModernNodeModuleKind: (module: ts.ModuleKind | undefined) => boolean;
export declare const tsTranspileModule: ExtendedTsTranspileModuleFn;
export {};

@@ -42,3 +42,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.tsTranspileModule = void 0;
exports.tsTranspileModule = exports.isModernNodeModuleKind = void 0;
var node_path_1 = __importDefault(require("node:path"));

@@ -61,2 +61,9 @@ var typescript_1 = __importDefault(require("typescript"));

}
var isModernNodeModuleKind = function (module) {
return module ? [typescript_1.default.ModuleKind.Node16, /* ModuleKind.Node18 */ 101, typescript_1.default.ModuleKind.NodeNext].includes(module) : false;
};
exports.isModernNodeModuleKind = isModernNodeModuleKind;
var shouldCheckProjectPkgJsonContent = function (fileName, moduleKind) {
return fileName.endsWith('package.json') && (0, exports.isModernNodeModuleKind)(moduleKind);
};
/**

@@ -70,3 +77,3 @@ * Copy source code of {@link ts.transpileModule} from {@link https://github.com/microsoft/TypeScript/blob/main/src/services/transpile.ts}

var e_1, _a;
var _b, _c, _d, _e;
var _b, _c, _d, _e, _f;
barebonesLibSourceFile !== null && barebonesLibSourceFile !== void 0 ? barebonesLibSourceFile : (barebonesLibSourceFile = typescript_1.default.createSourceFile(barebonesLibName, barebonesLibContent, {

@@ -89,4 +96,4 @@ languageVersion: typescript_1.default.ScriptTarget.Latest,

// @ts-expect-error internal TypeScript API
for (var _f = __values(typescript_1.default.transpileOptionValueCompilerOptions), _g = _f.next(); !_g.done; _g = _f.next()) {
var option = _g.value;
for (var _g = __values(typescript_1.default.transpileOptionValueCompilerOptions), _h = _g.next(); !_h.done; _h = _g.next()) {
var option = _h.value;
// Do not set redundant config options if `verbatimModuleSyntax` was supplied.

@@ -102,3 +109,3 @@ if (options.verbatimModuleSyntax && new Set(['isolatedModules']).has(option.name)) {

try {
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
}

@@ -140,6 +147,12 @@ finally { if (e_1) throw e_1.error; }

fileExists: function (fileName) {
return fileName.endsWith('package.json') ? typescript_1.default.sys.fileExists(fileName) : fileName === inputFileName;
if (shouldCheckProjectPkgJsonContent(fileName, options.module)) {
return typescript_1.default.sys.fileExists(fileName);
}
return fileName === inputFileName;
},
readFile: function (fileName) {
return fileName.endsWith('package.json') ? typescript_1.default.sys.readFile(fileName) : '';
if (shouldCheckProjectPkgJsonContent(fileName, options.module)) {
return typescript_1.default.sys.readFile(fileName);
}
return '';
},

@@ -178,3 +191,3 @@ directoryExists: function () { return true; },

/*cancellationToken*/ undefined,
/*emitOnlyDtsFiles*/ undefined, transpileOptions.transformers);
/*emitOnlyDtsFiles*/ undefined, (_f = transpileOptions.transformers) === null || _f === void 0 ? void 0 : _f.call(transpileOptions, program));
diagnostics.push.apply(diagnostics, __spreadArray([], __read(result.diagnostics), false));

@@ -181,0 +194,0 @@ if (outputText === undefined) {

{
"name": "ts-jest",
"version": "29.3.0",
"version": "29.3.1",
"main": "dist/index.js",

@@ -62,3 +62,3 @@ "types": "dist/index.d.ts",

"semver": "^7.7.1",
"type-fest": "^4.37.0",
"type-fest": "^4.38.0",
"yargs-parser": "^21.1.1"

@@ -109,8 +109,8 @@ },

"@types/micromatch": "^4.0.9",
"@types/node": "20.17.25",
"@types/semver": "^7.5.8",
"@types/node": "20.17.28",
"@types/semver": "^7.7.0",
"@types/yargs": "^17.0.33",
"@types/yargs-parser": "21.0.3",
"@typescript-eslint/eslint-plugin": "^8.27.0",
"@typescript-eslint/parser": "^8.27.0",
"@typescript-eslint/eslint-plugin": "^8.28.0",
"@typescript-eslint/parser": "^8.28.0",
"babel-jest": "^29.7.0",

@@ -138,3 +138,3 @@ "conventional-changelog-cli": "^5.0.0",

"typescript": "~5.5.4",
"typescript-eslint": "^8.27.0"
"typescript-eslint": "^8.28.0"
},

@@ -141,0 +141,0 @@ "engines": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display