Socket
Socket
Sign inDemoInstall

ts-node

Package Overview
Dependencies
Maintainers
2
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-node - npm Package Compare versions

Comparing version 10.8.2 to 10.9.0

dist/child/argv-payload.d.ts

96

dist/bin.js

@@ -29,3 +29,4 @@ #!/usr/bin/env node

isInChildProcess: false,
entrypoint: __filename,
isCli: true,
tsNodeScript: __filename,
parseArgvResult: args,

@@ -41,2 +42,4 @@ };

if (state.shouldUseChildProcess && !state.isInChildProcess) {
// Note: When transitioning into the child-process after `phase2`,
// the updated working directory needs to be preserved.
return (0, spawn_child_1.callInChild)(state);

@@ -48,2 +51,4 @@ }

if (state.shouldUseChildProcess && !state.isInChildProcess) {
// Note: When transitioning into the child-process after `phase2`,
// the updated working directory needs to be preserved.
return (0, spawn_child_1.callInChild)(state);

@@ -183,3 +188,3 @@ }

function phase2(payload) {
const { help, version, code, interactive, cwdArg, restArgs, esm } = payload.parseArgvResult;
const { help, version, cwdArg, esm } = payload.parseArgvResult;
if (help) {

@@ -234,22 +239,9 @@ console.log(`

}
// Figure out which we are executing: piped stdin, --eval, REPL, and/or entrypoint
// This is complicated because node's behavior is complicated
// `node -e code -i ./script.js` ignores -e
const executeEval = code != null && !(interactive && restArgs.length);
const executeEntrypoint = !executeEval && restArgs.length > 0;
const executeRepl = !executeEntrypoint &&
(interactive || (process.stdin.isTTY && !executeEval));
const executeStdin = !executeEval && !executeRepl && !executeEntrypoint;
const cwd = cwdArg || process.cwd();
/** Unresolved. May point to a symlink, not realpath. May be missing file extension */
const scriptPath = executeEntrypoint ? (0, path_1.resolve)(cwd, restArgs[0]) : undefined;
const cwd = cwdArg ? (0, path_1.resolve)(cwdArg) : process.cwd();
// If ESM is explicitly enabled through the flag, stage3 should be run in a child process
// with the ESM loaders configured.
if (esm)
payload.shouldUseChildProcess = true;
return {
executeEval,
executeEntrypoint,
executeRepl,
executeStdin,
cwd,
scriptPath,
};

@@ -259,3 +251,10 @@ }

const { emit, files, pretty, transpileOnly, transpiler, noExperimentalReplAwait, typeCheck, swc, compilerHost, ignore, preferTsExts, logError, scriptMode, cwdMode, project, skipProject, skipIgnore, compiler, ignoreDiagnostics, compilerOptions, argsRequire, scope, scopeDir, esm, experimentalSpecifierResolution, } = payload.parseArgvResult;
const { cwd, scriptPath } = payload.phase2Result;
const { cwd } = payload.phase2Result;
// NOTE: When we transition to a child process for ESM, the entry-point script determined
// here might not be the one used later in `phase4`. This can happen when we execute the
// original entry-point but then the process forks itself using e.g. `child_process.fork`.
// We will always use the original TS project in forked processes anyway, so it is
// expected and acceptable to retrieve the entry-point information here in `phase2`.
// See: https://github.com/TypeStrong/ts-node/issues/1812.
const { entryPointPath } = getEntryPointInfo(payload);
const preloadedConfig = (0, configuration_1.findAndReadConfig)({

@@ -274,3 +273,3 @@ cwd,

logError,
projectSearchDir: getProjectSearchDir(cwd, scriptMode, cwdMode, scriptPath),
projectSearchDir: getProjectSearchDir(cwd, scriptMode, cwdMode, entryPointPath),
project,

@@ -289,2 +288,4 @@ skipProject,

});
// If ESM is enabled through the parsed tsconfig, stage4 should be run in a child
// process with the ESM loaders configured.
if (preloadedConfig.options.esm)

@@ -294,8 +295,53 @@ payload.shouldUseChildProcess = true;

}
/**
* Determines the entry-point information from the argv and phase2 result. This
* method will be invoked in two places:
*
* 1. In phase 3 to be able to find a project from the potential entry-point script.
* 2. In phase 4 to determine the actual entry-point script.
*
* Note that we need to explicitly re-resolve the entry-point information in the final
* stage because the previous stage information could be modified when the bootstrap
* invocation transitioned into a child process for ESM.
*
* Stages before (phase 4) can and will be cached by the child process through the Brotli
* configuration and entry-point information is only reliable in the final phase. More
* details can be found in here: https://github.com/TypeStrong/ts-node/issues/1812.
*/
function getEntryPointInfo(state) {
const { code, interactive, restArgs } = state.parseArgvResult;
const { cwd } = state.phase2Result;
const { isCli } = state;
// Figure out which we are executing: piped stdin, --eval, REPL, and/or entrypoint
// This is complicated because node's behavior is complicated
// `node -e code -i ./script.js` ignores -e
const executeEval = code != null && !(interactive && restArgs.length);
const executeEntrypoint = !executeEval && restArgs.length > 0;
const executeRepl = !executeEntrypoint &&
(interactive || (process.stdin.isTTY && !executeEval));
const executeStdin = !executeEval && !executeRepl && !executeEntrypoint;
/**
* Unresolved. May point to a symlink, not realpath. May be missing file extension
* NOTE: resolution relative to cwd option (not `process.cwd()`) is legacy backwards-compat; should be changed in next major: https://github.com/TypeStrong/ts-node/issues/1834
*/
const entryPointPath = executeEntrypoint
? isCli
? (0, path_1.resolve)(cwd, restArgs[0])
: (0, path_1.resolve)(restArgs[0])
: undefined;
return {
executeEval,
executeEntrypoint,
executeRepl,
executeStdin,
entryPointPath,
};
}
function phase4(payload) {
var _a, _b, _c, _d, _e, _f, _g;
const { isInChildProcess, entrypoint } = payload;
const { isInChildProcess, tsNodeScript } = payload;
const { version, showConfig, restArgs, code, print, argv } = payload.parseArgvResult;
const { executeEval, cwd, executeStdin, executeRepl, executeEntrypoint, scriptPath, } = payload.phase2Result;
const { cwd } = payload.phase2Result;
const { preloadedConfig } = payload.phase3Result;
const { entryPointPath, executeEntrypoint, executeEval, executeRepl, executeStdin, } = getEntryPointInfo(payload);
let evalStuff;

@@ -416,6 +462,6 @@ let replStuff;

// Prepend `ts-node` arguments to CLI for child processes.
process.execArgv.push(entrypoint, ...argv.slice(2, argv.length - restArgs.length));
// TODO this comes from BoostrapState
process.execArgv.push(tsNodeScript, ...argv.slice(2, argv.length - restArgs.length));
// TODO this comes from BootstrapState
process.argv = [process.argv[1]]
.concat(executeEntrypoint ? [scriptPath] : [])
.concat(executeEntrypoint ? [entryPointPath] : [])
.concat(restArgs.slice(executeEntrypoint ? 1 : 0));

@@ -422,0 +468,0 @@ // Execute the main contents (either eval, script or piped).

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const bin_1 = require("../bin");
const zlib_1 = require("zlib");
const argv_payload_1 = require("./argv-payload");
const base64ConfigArg = process.argv[2];
const argPrefix = '--brotli-base64-config=';
if (!base64ConfigArg.startsWith(argPrefix))
if (!base64ConfigArg.startsWith(argv_payload_1.argPrefix))
throw new Error('unexpected argv');
const base64Payload = base64ConfigArg.slice(argPrefix.length);
const payload = JSON.parse((0, zlib_1.brotliDecompressSync)(Buffer.from(base64Payload, 'base64')).toString());
payload.isInChildProcess = true;
payload.entrypoint = __filename;
payload.parseArgvResult.argv = process.argv;
payload.parseArgvResult.restArgs = process.argv.slice(3);
(0, bin_1.bootstrap)(payload);
const base64Payload = base64ConfigArg.slice(argv_payload_1.argPrefix.length);
const state = (0, argv_payload_1.decompress)(base64Payload);
state.isInChildProcess = true;
state.tsNodeScript = __filename;
state.parseArgvResult.argv = process.argv;
state.parseArgvResult.restArgs = process.argv.slice(3);
// Modify and re-compress the payload delivered to subsequent child processes.
// This logic may be refactored into bin.ts by https://github.com/TypeStrong/ts-node/issues/1831
if (state.isCli) {
const stateForChildren = {
...state,
isCli: false,
};
state.parseArgvResult.argv[2] = `${argv_payload_1.argPrefix}${(0, argv_payload_1.compress)(stateForChildren)}`;
}
(0, bin_1.bootstrap)(state);
//# sourceMappingURL=child-entrypoint.js.map

@@ -5,7 +5,11 @@ "use strict";

const child_process_1 = require("child_process");
const zlib_1 = require("zlib");
const url_1 = require("url");
const util_1 = require("../util");
const argPrefix = '--brotli-base64-config=';
/** @internal */
const argv_payload_1 = require("./argv-payload");
/**
* @internal
* @param state Bootstrap state to be transferred into the child process.
* @param targetCwd Working directory to be preserved when transitioning to
* the child process.
*/
function callInChild(state) {

@@ -22,3 +26,3 @@ if (!(0, util_1.versionGteLt)(process.versions.node, '12.17.0')) {

require.resolve('./child-entrypoint.js'),
`${argPrefix}${(0, zlib_1.brotliCompressSync)(Buffer.from(JSON.stringify(state), 'utf8')).toString('base64')}`,
`${argv_payload_1.argPrefix}${(0, argv_payload_1.compress)(state)}`,
...state.parseArgvResult.restArgs,

@@ -25,0 +29,0 @@ ], {

@@ -94,5 +94,10 @@ "use strict";

if (!skipProject) {
configFilePath = project
? (0, path_1.resolve)(cwd, project)
: ts.findConfigFile(projectSearchDir, fileExists);
if (project) {
const resolved = (0, path_1.resolve)(cwd, project);
const nested = (0, path_1.join)(resolved, 'tsconfig.json');
configFilePath = fileExists(nested) ? nested : resolved;
}
else {
configFilePath = ts.findConfigFile(projectSearchDir, fileExists);
}
if (configFilePath) {

@@ -243,3 +248,3 @@ let pathToNextConfigInChain = configFilePath;

return { recognized: {}, unrecognized: {} };
const { compiler, compilerHost, compilerOptions, emit, files, ignore, ignoreDiagnostics, logError, preferTsExts, pretty, require, skipIgnore, transpileOnly, typeCheck, transpiler, scope, scopeDir, moduleTypes, experimentalReplAwait, swc, experimentalResolver, esm, experimentalSpecifierResolution, ...unrecognized } = jsonObject;
const { compiler, compilerHost, compilerOptions, emit, files, ignore, ignoreDiagnostics, logError, preferTsExts, pretty, require, skipIgnore, transpileOnly, typeCheck, transpiler, scope, scopeDir, moduleTypes, experimentalReplAwait, swc, experimentalResolver, esm, experimentalSpecifierResolution, experimentalTsImportSpecifiers, ...unrecognized } = jsonObject;
const filteredTsConfigOptions = {

@@ -269,2 +274,3 @@ compiler,

experimentalSpecifierResolution,
experimentalTsImportSpecifiers,
};

@@ -271,0 +277,0 @@ // Use the typechecker to make sure this implementation has the correct set of properties

@@ -12,2 +12,8 @@ "use strict";

]);
const tsResolverEquivalents = new Map([
['.ts', ['.js']],
['.tsx', ['.js', '.jsx']],
['.mts', ['.mjs']],
['.cts', ['.cjs']],
]);
// All extensions understood by vanilla node

@@ -96,2 +102,15 @@ const vanillaNodeExtensions = [

/**
* Mapping from extensions rejected by TSC in import specifiers, to the
* possible alternatives that TS's resolver will accept.
*
* When we allow users to opt-in to .ts extensions in import specifiers, TS's
* resolver requires us to replace the .ts extensions with .js alternatives.
* Otherwise, resolution fails.
*
* Note TS's resolver is only used by, and only required for, typechecking.
* This is separate from node's resolver, which we hook separately and which
* does not require this mapping.
*/
tsResolverEquivalents,
/**
* Extensions that we can support if the user upgrades their typescript version.

@@ -98,0 +117,0 @@ * Used when raising hints.

@@ -225,2 +225,13 @@ import { BaseError } from 'make-error';

experimentalSpecifierResolution?: 'node' | 'explicit';
/**
* Allow using voluntary `.ts` file extension in import specifiers.
*
* Typically, in ESM projects, import specifiers must have an emit extension, `.js`, `.cjs`, or `.mjs`,
* and we automatically map to the corresponding `.ts`, `.cts`, or `.mts` source file. This is the
* recommended approach.
*
* However, if you really want to use `.ts` in import specifiers, and are aware that this may
* break tooling, you can enable this flag.
*/
experimentalTsImportSpecifiers?: boolean;
}

@@ -227,0 +238,0 @@ export declare type ModuleTypes = Record<string, ModuleTypeOverride>;

@@ -204,2 +204,7 @@ "use strict";

18003,
...(options.experimentalTsImportSpecifiers
? [
2691, // "An import path cannot end with a '.ts' extension. Consider importing '<specifier without ext>' instead."
]
: []),
...(options.ignoreDiagnostics || []),

@@ -360,2 +365,3 @@ ].map(Number),

});
const extensions = (0, file_extensions_1.getExtensions)(config, options, ts.version);
// Use full language services when the fast option is disabled.

@@ -422,2 +428,4 @@ if (!transpileOnly) {

projectLocalResolveHelper,
options,
extensions,
});

@@ -534,2 +542,4 @@ serviceHost.resolveModuleNames = resolveModuleNames;

projectLocalResolveHelper,
options,
extensions,
});

@@ -745,3 +755,2 @@ host.resolveModuleNames = resolveModuleNames;

const enabled = (enabled) => enabled === undefined ? active : (active = !!enabled);
const extensions = (0, file_extensions_1.getExtensions)(config, options, ts.version);
const ignored = (fileName) => {

@@ -748,0 +757,0 @@ if (!active)

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

context,
overrideIsCompletion: false,
});

@@ -346,3 +347,3 @@ assert(result.containsTopLevelAwait === false);

function appendCompileAndEvalInput(options) {
const { service, state, wrappedErr, enableTopLevelAwait = false, context, } = options;
const { service, state, wrappedErr, enableTopLevelAwait = false, context, overrideIsCompletion, } = options;
let { input } = options;

@@ -359,3 +360,3 @@ // It's confusing for `{ a: 1 }` to be interpreted as a block statement

const lines = state.lines;
const isCompletion = !/\n$/.test(input);
const isCompletion = overrideIsCompletion !== null && overrideIsCompletion !== void 0 ? overrideIsCompletion : !/\n$/.test(input);
const undo = appendToEvalState(state, input);

@@ -362,0 +363,0 @@ let output;

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

function createResolverFunctions(kwargs) {
const { host, ts, config, cwd, getCanonicalFileName, projectLocalResolveHelper, } = kwargs;
const { host, ts, config, cwd, getCanonicalFileName, projectLocalResolveHelper, options, extensions, } = kwargs;
const moduleResolutionCache = ts.createModuleResolutionCache(cwd, getCanonicalFileName, config.options);

@@ -72,3 +72,15 @@ const knownInternalFilenames = new Set();

: undefined;
const { resolvedModule } = ts.resolveModuleName(moduleName, containingFile, config.options, host, moduleResolutionCache, redirectedReference, mode);
let { resolvedModule } = ts.resolveModuleName(moduleName, containingFile, config.options, host, moduleResolutionCache, redirectedReference, mode);
if (!resolvedModule && options.experimentalTsImportSpecifiers) {
const lastDotIndex = moduleName.lastIndexOf('.');
const ext = lastDotIndex >= 0 ? moduleName.slice(lastDotIndex) : '';
if (ext) {
const replacements = extensions.tsResolverEquivalents.get(ext);
for (const replacementExt of replacements !== null && replacements !== void 0 ? replacements : []) {
({ resolvedModule } = ts.resolveModuleName(moduleName.slice(0, -ext.length) + replacementExt, containingFile, config.options, host, moduleResolutionCache, redirectedReference, mode));
if (resolvedModule)
break;
}
}
}
if (resolvedModule) {

@@ -75,0 +87,0 @@ fixupResolvedModule(resolvedModule);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.targetMapping = exports.create = void 0;
exports.createSwcOptions = exports.targetMapping = exports.create = void 0;
function create(createOptions) {

@@ -8,3 +8,6 @@ const { swc, service: { config, projectLocalResolveHelper }, transpilerConfigLocalResolveHelper, nodeModuleEmitKind, } = createOptions;

let swcInstance;
// Used later in diagnostics; merely needs to be human-readable.
let swcDepName = 'swc';
if (typeof swc === 'string') {
swcDepName = swc;
swcInstance = require(transpilerConfigLocalResolveHelper(swc, true));

@@ -15,7 +18,9 @@ }

try {
swcResolved = transpilerConfigLocalResolveHelper('@swc/core', true);
swcDepName = '@swc/core';
swcResolved = transpilerConfigLocalResolveHelper(swcDepName, true);
}
catch (e) {
try {
swcResolved = transpilerConfigLocalResolveHelper('@swc/wasm', true);
swcDepName = '@swc/wasm';
swcResolved = transpilerConfigLocalResolveHelper(swcDepName, true);
}

@@ -32,89 +37,3 @@ catch (e) {

// Prepare SWC options derived from typescript compiler options
const compilerOptions = config.options;
const { esModuleInterop, sourceMap, importHelpers, experimentalDecorators, emitDecoratorMetadata, target, module, jsxFactory, jsxFragmentFactory, strict, alwaysStrict, noImplicitUseStrict, } = compilerOptions;
const nonTsxOptions = createSwcOptions(false);
const tsxOptions = createSwcOptions(true);
function createSwcOptions(isTsx) {
var _a;
let swcTarget = (_a = exports.targetMapping.get(target)) !== null && _a !== void 0 ? _a : 'es3';
// Downgrade to lower target if swc does not support the selected target.
// Perhaps project has an older version of swc.
// TODO cache the results of this; slightly faster
let swcTargetIndex = swcTargets.indexOf(swcTarget);
for (; swcTargetIndex >= 0; swcTargetIndex--) {
try {
swcInstance.transformSync('', {
jsc: { target: swcTargets[swcTargetIndex] },
});
break;
}
catch (e) { }
}
swcTarget = swcTargets[swcTargetIndex];
const keepClassNames = target >= /* ts.ScriptTarget.ES2016 */ 3;
const isNodeModuleKind = module === ModuleKind.Node12 || module === ModuleKind.NodeNext;
// swc only supports these 4x module options [MUST_UPDATE_FOR_NEW_MODULEKIND]
const moduleType = module === ModuleKind.CommonJS
? 'commonjs'
: module === ModuleKind.AMD
? 'amd'
: module === ModuleKind.UMD
? 'umd'
: isNodeModuleKind && nodeModuleEmitKind === 'nodecjs'
? 'commonjs'
: isNodeModuleKind && nodeModuleEmitKind === 'nodeesm'
? 'es6'
: 'es6';
// In swc:
// strictMode means `"use strict"` is *always* emitted for non-ES module, *never* for ES module where it is assumed it can be omitted.
// (this assumption is invalid, but that's the way swc behaves)
// tsc is a bit more complex:
// alwaysStrict will force emitting it always unless `import`/`export` syntax is emitted which implies it per the JS spec.
// if not alwaysStrict, will emit implicitly whenever module target is non-ES *and* transformed module syntax is emitted.
// For node, best option is to assume that all scripts are modules (commonjs or esm) and thus should get tsc's implicit strict behavior.
// Always set strictMode, *unless* alwaysStrict is disabled and noImplicitUseStrict is enabled
const strictMode =
// if `alwaysStrict` is disabled, remembering that `strict` defaults `alwaysStrict` to true
(alwaysStrict === false || (alwaysStrict !== true && strict !== true)) &&
// if noImplicitUseStrict is enabled
noImplicitUseStrict === true
? false
: true;
return {
sourceMaps: sourceMap,
// isModule: true,
module: moduleType
? {
noInterop: !esModuleInterop,
type: moduleType,
strictMode,
// For NodeNext and Node12, emit as CJS but do not transform dynamic imports
ignoreDynamic: nodeModuleEmitKind === 'nodecjs',
}
: undefined,
swcrc: false,
jsc: {
externalHelpers: importHelpers,
parser: {
syntax: 'typescript',
tsx: isTsx,
decorators: experimentalDecorators,
dynamicImport: true,
},
target: swcTarget,
transform: {
decoratorMetadata: emitDecoratorMetadata,
legacyDecorator: true,
react: {
throwIfNamespace: false,
development: false,
useBuiltins: false,
pragma: jsxFactory,
pragmaFrag: jsxFragmentFactory,
},
},
keepClassNames,
},
};
}
const { nonTsxOptions, tsxOptions } = createSwcOptions(config.options, nodeModuleEmitKind, swcInstance, swcDepName);
const transpile = (input, transpileOptions) => {

@@ -174,5 +93,124 @@ const { fileName } = transpileOptions;

ESNext: 99,
Node12: 100,
Node16: 100,
NodeNext: 199,
};
const JsxEmit = {
ReactJSX: /* ts.JsxEmit.ReactJSX */ 4,
ReactJSXDev: /* ts.JsxEmit.ReactJSXDev */ 5,
};
/**
* Prepare SWC options derived from typescript compiler options.
* @internal exported for testing
*/
function createSwcOptions(compilerOptions, nodeModuleEmitKind, swcInstance, swcDepName) {
var _a;
const { esModuleInterop, sourceMap, importHelpers, experimentalDecorators, emitDecoratorMetadata, target, module, jsx, jsxFactory, jsxFragmentFactory, strict, alwaysStrict, noImplicitUseStrict, } = compilerOptions;
let swcTarget = (_a = exports.targetMapping.get(target)) !== null && _a !== void 0 ? _a : 'es3';
// Downgrade to lower target if swc does not support the selected target.
// Perhaps project has an older version of swc.
// TODO cache the results of this; slightly faster
let swcTargetIndex = swcTargets.indexOf(swcTarget);
for (; swcTargetIndex >= 0; swcTargetIndex--) {
try {
swcInstance.transformSync('', {
jsc: { target: swcTargets[swcTargetIndex] },
});
break;
}
catch (e) { }
}
swcTarget = swcTargets[swcTargetIndex];
const keepClassNames = target >= /* ts.ScriptTarget.ES2016 */ 3;
const isNodeModuleKind = module === ModuleKind.Node16 || module === ModuleKind.NodeNext;
// swc only supports these 4x module options [MUST_UPDATE_FOR_NEW_MODULEKIND]
const moduleType = module === ModuleKind.CommonJS
? 'commonjs'
: module === ModuleKind.AMD
? 'amd'
: module === ModuleKind.UMD
? 'umd'
: isNodeModuleKind && nodeModuleEmitKind === 'nodecjs'
? 'commonjs'
: isNodeModuleKind && nodeModuleEmitKind === 'nodeesm'
? 'es6'
: 'es6';
// In swc:
// strictMode means `"use strict"` is *always* emitted for non-ES module, *never* for ES module where it is assumed it can be omitted.
// (this assumption is invalid, but that's the way swc behaves)
// tsc is a bit more complex:
// alwaysStrict will force emitting it always unless `import`/`export` syntax is emitted which implies it per the JS spec.
// if not alwaysStrict, will emit implicitly whenever module target is non-ES *and* transformed module syntax is emitted.
// For node, best option is to assume that all scripts are modules (commonjs or esm) and thus should get tsc's implicit strict behavior.
// Always set strictMode, *unless* alwaysStrict is disabled and noImplicitUseStrict is enabled
const strictMode =
// if `alwaysStrict` is disabled, remembering that `strict` defaults `alwaysStrict` to true
(alwaysStrict === false || (alwaysStrict !== true && strict !== true)) &&
// if noImplicitUseStrict is enabled
noImplicitUseStrict === true
? false
: true;
const jsxRuntime = jsx === JsxEmit.ReactJSX || jsx === JsxEmit.ReactJSXDev
? 'automatic'
: undefined;
const jsxDevelopment = jsx === JsxEmit.ReactJSXDev ? true : undefined;
const nonTsxOptions = createVariant(false);
const tsxOptions = createVariant(true);
return { nonTsxOptions, tsxOptions };
function createVariant(isTsx) {
const swcOptions = {
sourceMaps: sourceMap,
// isModule: true,
module: moduleType
? {
noInterop: !esModuleInterop,
type: moduleType,
strictMode,
// For NodeNext and Node12, emit as CJS but do not transform dynamic imports
ignoreDynamic: nodeModuleEmitKind === 'nodecjs',
}
: undefined,
swcrc: false,
jsc: {
externalHelpers: importHelpers,
parser: {
syntax: 'typescript',
tsx: isTsx,
decorators: experimentalDecorators,
dynamicImport: true,
importAssertions: true,
},
target: swcTarget,
transform: {
decoratorMetadata: emitDecoratorMetadata,
legacyDecorator: true,
react: {
throwIfNamespace: false,
development: jsxDevelopment,
useBuiltins: false,
pragma: jsxFactory,
pragmaFrag: jsxFragmentFactory,
runtime: jsxRuntime,
},
},
keepClassNames,
experimental: {
keepImportAssertions: true,
},
},
};
// Throw a helpful error if swc version is old, for example, if it rejects `ignoreDynamic`
try {
swcInstance.transformSync('', swcOptions);
}
catch (e) {
throw new Error(`${swcDepName} threw an error when attempting to validate swc compiler options.\n` +
'You may be using an old version of swc which does not support the options used by ts-node.\n' +
'Try upgrading to the latest version of swc.\n' +
'Error message from swc:\n' +
(e === null || e === void 0 ? void 0 : e.message));
}
return swcOptions;
}
}
exports.createSwcOptions = createSwcOptions;
//# sourceMappingURL=swc.js.map
{
"name": "ts-node",
"version": "10.8.2",
"version": "10.9.0",
"description": "TypeScript execution environment and REPL for node.js, with source map support",

@@ -115,4 +115,4 @@ "main": "dist/index.js",

"@microsoft/api-extractor": "^7.19.4",
"@swc/core": ">=1.2.50",
"@swc/wasm": ">=1.2.50",
"@swc/core": ">=1.2.205",
"@swc/wasm": ">=1.2.205",
"@types/diff": "^4.0.2",

@@ -135,2 +135,3 @@ "@types/lodash": "^4.14.151",

"nyc": "^15.0.1",
"outdent": "^0.8.0",
"proper-lockfile": "^4.1.2",

@@ -143,3 +144,3 @@ "proxyquire": "^2.0.0",

"typedoc": "^0.22.10",
"typescript": "4.7.2",
"typescript": "4.7.4",
"typescript-json-schema": "^0.53.0",

@@ -146,0 +147,0 @@ "util.promisify": "^1.0.1"

@@ -1060,4 +1060,6 @@ <!--

It is often better to use `tsc --noEmit` to typecheck as part of your tests or linting. In these cases, ts-node can skip typechecking.
It is often better to typecheck as part of your tests or linting. You can run `tsc --noEmit` to do this. In these cases, ts-node can skip typechecking, making it much faster.
To skip typechecking in ts-node, do one of the following:
* Enable [swc](#swc)

@@ -1069,2 +1071,4 @@ * This is by far the fastest option

If you absolutely must typecheck in ts-node:
* Avoid dynamic `require()` which may trigger repeated typechecking; prefer `import`

@@ -1071,0 +1075,0 @@ * Try with and without `--files`; one may be faster depending on your project

@@ -57,2 +57,6 @@ {

},
"experimentalTsImportSpecifiers": {
"description": "Allow using voluntary `.ts` file extension in import specifiers.\n\nTypically, in ESM projects, import specifiers must have an emit extension, `.js`, `.cjs`, or `.mjs`,\nand we automatically map to the corresponding `.ts`, `.cts`, or `.mts` source file. This is the\nrecommended approach.\n\nHowever, if you really want to use `.ts` in import specifiers, and are aware that this may\nbreak tooling, you can enable this flag.",
"type": "boolean"
},
"files": {

@@ -59,0 +63,0 @@ "default": false,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc