🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

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

to
10.4.0

1

dist-raw/node-primordials.js

@@ -19,2 +19,3 @@ module.exports = {

ObjectPrototypeHasOwnProperty: (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop),
RegExpPrototypeExec: (obj, string) => RegExp.prototype.exec.call(obj, string),
RegExpPrototypeTest: (obj, string) => RegExp.prototype.test.call(obj, string),

@@ -21,0 +22,0 @@ RegExpPrototypeSymbolReplace: (obj, ...rest) => RegExp.prototype[Symbol.replace].apply(obj, rest),

50

dist/esm.d.ts
/// <reference types="node" />
import { Service } from './index';
export declare function createEsmHooks(tsNodeService: Service): {
resolve: (specifier: string, context: {
export interface NodeLoaderHooksAPI1 {
resolve: NodeLoaderHooksAPI1.ResolveHook;
getFormat: NodeLoaderHooksAPI1.GetFormatHook;
transformSource: NodeLoaderHooksAPI1.TransformSourceHook;
}
export declare namespace NodeLoaderHooksAPI1 {
type ResolveHook = NodeLoaderHooksAPI2.ResolveHook;
type GetFormatHook = (url: string, context: {}, defaultGetFormat: GetFormatHook) => Promise<{
format: NodeLoaderHooksFormat;
}>;
type TransformSourceHook = (source: string | Buffer, context: {
url: string;
format: NodeLoaderHooksFormat;
}, defaultTransformSource: NodeLoaderHooksAPI1.TransformSourceHook) => Promise<{
source: string | Buffer;
}>;
}
export interface NodeLoaderHooksAPI2 {
resolve: NodeLoaderHooksAPI2.ResolveHook;
load: NodeLoaderHooksAPI2.LoadHook;
}
export declare namespace NodeLoaderHooksAPI2 {
type ResolveHook = (specifier: string, context: {
parentURL: string;
}, defaultResolve: any) => Promise<{
}, defaultResolve: ResolveHook) => Promise<{
url: string;
}>;
getFormat: ((url: string, context: {}, defaultGetFormat: any) => Promise<{
format: "module" | "builtin" | "commonjs" | "dynamic" | "json" | "wasm";
}>) | undefined;
transformSource: ((source: string | Buffer, context: {
url: string;
format: "module" | "builtin" | "commonjs" | "dynamic" | "json" | "wasm";
}, defaultTransformSource: any) => Promise<{
source: string | Buffer;
}>) | undefined;
load: ((url: string, context: {
format: ("module" | "builtin" | "commonjs" | "dynamic" | "json" | "wasm") | null | undefined;
}, defaultLoad: any) => Promise<{
format: "module" | "builtin" | "commonjs" | "dynamic" | "json" | "wasm";
type LoadHook = (url: string, context: {
format: NodeLoaderHooksFormat | null | undefined;
}, defaultLoad: NodeLoaderHooksAPI2['load']) => Promise<{
format: NodeLoaderHooksFormat;
source: string | Buffer | undefined;
}>) | undefined;
};
}>;
}
export declare type NodeLoaderHooksFormat = 'builtin' | 'commonjs' | 'dynamic' | 'json' | 'module' | 'wasm';
export declare function createEsmHooks(tsNodeService: Service): NodeLoaderHooksAPI1 | NodeLoaderHooksAPI2;

@@ -20,16 +20,2 @@ "use strict";

const { defaultGetFormat } = require('../dist-raw/node-esm-default-get-format');
// Note: On Windows, URLs look like this: file:///D:/dev/@TypeStrong/ts-node-examples/foo.ts
// NOTE ABOUT MULTIPLE EXPERIMENTAL LOADER APIS
//
// At the time of writing, this file implements 2x different loader APIs.
// Node made a breaking change to the loader API in https://github.com/nodejs/node/pull/37468
//
// We check the node version number and export either the *old* or the *new* API.
//
// Today, we are implementing the *new* API on top of our implementation of the *old* API,
// which relies on copy-pasted code from the *old* hooks implementation in node.
//
// In the future, we will likely invert this: we will copy-paste the *new* API implementation
// from node, build our implementation of the *new* API on top of it, and implement the *old*
// hooks API as a shim to the *new* API.
/** @internal */

@@ -36,0 +22,0 @@ function registerAndCreateEsmHooks(opts) {

import { BaseError } from 'make-error';
import type * as _ts from 'typescript';
import type { TSCommon } from './ts-compiler-types';
import type { createEsmHooks as createEsmHooksFn } from './esm';
export { TSCommon };
export { createRepl, CreateReplOptions, ReplService, EvalAwarePartialHost, } from './repl';
export type { TranspilerModule, TranspilerFactory, CreateTranspilerOptions, TranspileOutput, TranspileOptions, Transpiler, } from './transpilers/types';
export type { NodeLoaderHooksAPI1, NodeLoaderHooksAPI2, NodeLoaderHooksFormat, } from './esm';
/**

@@ -251,3 +253,12 @@ * Registered `ts-node` instance information.

export declare function create(rawOptions?: CreateOptions): Service;
import type { createEsmHooks as createEsmHooksFn } from './esm';
/**
* Create an implementation of node's ESM loader hooks.
*
* This may be useful if you
* want to wrap or compose the loader hooks to add additional functionality or
* combine with another loader.
*
* Node changed the hooks API, so there are two possible APIs. This function
* detects your node version and returns the appropriate API.
*/
export declare const createEsmHooks: typeof createEsmHooksFn;

@@ -817,4 +817,14 @@ "use strict";

}
/**
* Create an implementation of node's ESM loader hooks.
*
* This may be useful if you
* want to wrap or compose the loader hooks to add additional functionality or
* combine with another loader.
*
* Node changed the hooks API, so there are two possible APIs. This function
* detects your node version and returns the appropriate API.
*/
const createEsmHooks = (tsNodeService) => require('./esm').createEsmHooks(tsNodeService);
exports.createEsmHooks = createEsmHooks;
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.create = void 0;
exports.targetMapping = exports.create = void 0;
function create(createOptions) {

@@ -36,3 +36,17 @@ const { swc, service: { config }, } = createOptions;

var _a;
const swcTarget = (_a = targetMapping.get(target)) !== null && _a !== void 0 ? _a : 'es3';
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;

@@ -93,12 +107,29 @@ const moduleType = module === ModuleKind.CommonJS

exports.create = create;
const targetMapping = new Map();
targetMapping.set(/* ts.ScriptTarget.ES3 */ 0, 'es3');
targetMapping.set(/* ts.ScriptTarget.ES5 */ 1, 'es5');
targetMapping.set(/* ts.ScriptTarget.ES2015 */ 2, 'es2015');
targetMapping.set(/* ts.ScriptTarget.ES2016 */ 3, 'es2016');
targetMapping.set(/* ts.ScriptTarget.ES2017 */ 4, 'es2017');
targetMapping.set(/* ts.ScriptTarget.ES2018 */ 5, 'es2018');
targetMapping.set(/* ts.ScriptTarget.ES2019 */ 6, 'es2019');
targetMapping.set(/* ts.ScriptTarget.ES2020 */ 7, 'es2019');
targetMapping.set(/* ts.ScriptTarget.ESNext */ 99, 'es2019');
/** @internal */
exports.targetMapping = new Map();
exports.targetMapping.set(/* ts.ScriptTarget.ES3 */ 0, 'es3');
exports.targetMapping.set(/* ts.ScriptTarget.ES5 */ 1, 'es5');
exports.targetMapping.set(/* ts.ScriptTarget.ES2015 */ 2, 'es2015');
exports.targetMapping.set(/* ts.ScriptTarget.ES2016 */ 3, 'es2016');
exports.targetMapping.set(/* ts.ScriptTarget.ES2017 */ 4, 'es2017');
exports.targetMapping.set(/* ts.ScriptTarget.ES2018 */ 5, 'es2018');
exports.targetMapping.set(/* ts.ScriptTarget.ES2019 */ 6, 'es2019');
exports.targetMapping.set(/* ts.ScriptTarget.ES2020 */ 7, 'es2020');
exports.targetMapping.set(/* ts.ScriptTarget.ES2021 */ 8, 'es2021');
exports.targetMapping.set(/* ts.ScriptTarget.ESNext */ 99, 'es2021');
/**
* @internal
* We use this list to downgrade to a prior target when we probe swc to detect if it supports a particular target
*/
const swcTargets = [
'es3',
'es5',
'es2015',
'es2016',
'es2017',
'es2018',
'es2019',
'es2020',
'es2021',
];
const ModuleKind = {

@@ -105,0 +136,0 @@ None: 0,

{
"name": "ts-node",
"version": "10.3.1",
"version": "10.4.0",
"description": "TypeScript execution environment and REPL for node.js, with source map support",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -127,3 +127,3 @@ <!--

**Tip:** Installing modules locally allows you to control and share the versions through `package.json`. TS Node will always resolve the compiler from `cwd` before checking relative to its own installation.
**Tip:** Installing modules locally allows you to control and share the versions through `package.json`. ts-node will always resolve the compiler from `cwd` before checking relative to its own installation.

@@ -652,6 +652,6 @@ # Usage

To use it, first install `@swc/core` or `@swc/wasm`. If using `importHelpers`, also install `@swc/helpers`.
To use it, first install `@swc/core` or `@swc/wasm`. If using `importHelpers`, also install `@swc/helpers`. If `target` is less than "es2015" and using either `async`/`await` or generator functions, also install `regenerator-runtime`.
```shell
npm i -D @swc/core @swc/helpers
npm i -D @swc/core @swc/helpers regenerator-runtime
```

@@ -658,0 +658,0 @@

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