Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swc-node/register

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swc-node/register - npm Package Compare versions

Comparing version 1.5.8 to 1.6.0

lib/esm.d.mts

6

lib/__test__/create-sourcemap-option.spec.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const ava_1 = tslib_1.__importDefault(require("ava"));
const ava_1 = __importDefault(require("ava"));
const read_default_tsconfig_1 = require("../read-default-tsconfig");

@@ -6,0 +8,0 @@ const FIXTURES = [

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path_1 = require("path");
const ava_1 = tslib_1.__importDefault(require("ava"));
const ava_1 = __importDefault(require("ava"));
const lodash_1 = require("lodash");
const sinon_1 = tslib_1.__importDefault(require("sinon"));
const ts = tslib_1.__importStar(require("typescript"));
const sinon_1 = __importDefault(require("sinon"));
const ts = __importStar(require("typescript"));
const read_default_tsconfig_1 = require("../read-default-tsconfig");

@@ -10,0 +35,0 @@ (0, ava_1.default)('should read tsconfig from cwd if without any config', (t) => {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.tsCompilerOptionsToSwcConfig = exports.createSourcemapOption = exports.readDefaultTsConfig = void 0;
const tslib_1 = require("tslib");
const fs_1 = require("fs");
const path_1 = require("path");
const colorette_1 = require("colorette");
const debug_1 = tslib_1.__importDefault(require("debug"));
const ts = tslib_1.__importStar(require("typescript"));
const debug_1 = __importDefault(require("debug"));
const ts = __importStar(require("typescript"));
const debug = (0, debug_1.default)('@swc-node');

@@ -65,6 +90,7 @@ function readDefaultTsConfig(tsConfigPath) {

case ts.ScriptTarget.ES2021:
return 'es2021';
case ts.ScriptTarget.ES2022:
case ts.ScriptTarget.ESNext:
case ts.ScriptTarget.Latest:
return 'es2021';
return 'es2022';
case ts.ScriptTarget.JSON:

@@ -108,8 +134,7 @@ return 'es5';

return {
target: toTsTarget((_a = options.target) !== null && _a !== void 0 ? _a : ts.ScriptTarget.ES2018),
module: toModule((_b = options.module) !== null && _b !== void 0 ? _b : ts.ModuleKind.ES2015),
module: toModule((_a = options.module) !== null && _a !== void 0 ? _a : ts.ModuleKind.ES2015),
sourcemap: createSourcemapOption(options),
experimentalDecorators: (_c = options.experimentalDecorators) !== null && _c !== void 0 ? _c : false,
emitDecoratorMetadata: (_d = options.emitDecoratorMetadata) !== null && _d !== void 0 ? _d : false,
esModuleInterop: (_e = options.esModuleInterop) !== null && _e !== void 0 ? _e : false,
experimentalDecorators: (_b = options.experimentalDecorators) !== null && _b !== void 0 ? _b : false,
emitDecoratorMetadata: (_c = options.emitDecoratorMetadata) !== null && _c !== void 0 ? _c : false,
esModuleInterop: (_d = options.esModuleInterop) !== null && _d !== void 0 ? _d : false,
swc: {

@@ -124,3 +149,3 @@ filename,

},
paths: Object.fromEntries(Object.entries((_f = options.paths) !== null && _f !== void 0 ? _f : {}).map(([aliasKey, aliasPaths]) => {
paths: Object.fromEntries(Object.entries((_e = options.paths) !== null && _e !== void 0 ? _e : {}).map(([aliasKey, aliasPaths]) => {
var _a;

@@ -133,2 +158,3 @@ return [

keepClassNames: true,
target: toTsTarget((_f = options.target) !== null && _f !== void 0 ? _f : ts.ScriptTarget.ES2018),
transform: {

@@ -135,0 +161,0 @@ react: options.jsxFactory || options.jsxFragmentFactory || options.jsx || options.jsxImportSource

@@ -5,4 +5,13 @@ import * as ts from 'typescript';

}): string;
export declare function compile(sourcecode: string, filename: string, options: ts.CompilerOptions & {
fallbackToTs?: (filename: string) => boolean;
}, async: false): string;
export declare function compile(sourcecode: string, filename: string, options: ts.CompilerOptions & {
fallbackToTs?: (filename: string) => boolean;
}, async: true): Promise<string>;
export declare function compile(sourcecode: string, filename: string, options: ts.CompilerOptions & {
fallbackToTs?: (filename: string) => boolean;
}, async: boolean): string | Promise<string>;
export declare function register(options?: Partial<ts.CompilerOptions & {
fallbackToTs: (path: string) => boolean;
}>, hookOpts?: {}): () => void;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = exports.compile = void 0;
const tslib_1 = require("tslib");
const os_1 = require("os");

@@ -10,7 +32,7 @@ const path_1 = require("path");

const pirates_1 = require("pirates");
const ts = tslib_1.__importStar(require("typescript"));
const ts = __importStar(require("typescript"));
const read_default_tsconfig_1 = require("./read-default-tsconfig");
const DEFAULT_EXTENSIONS = ['.js', '.jsx', '.es6', '.es', '.mjs', '.ts', '.tsx'];
const PLATFORM = (0, os_1.platform)();
function compile(sourcecode, filename, options) {
function compile(sourcecode, filename, options, async = false) {
if (filename.endsWith('.d.ts')) {

@@ -39,2 +61,11 @@ return '';

}
else if (async) {
return (0, core_1.transform)(sourcecode, filename, (0, read_default_tsconfig_1.tsCompilerOptionsToSwcConfig)(options, filename)).then(({ code, map }) => {
// in case of map is undefined
if (map) {
sourcemap_support_1.SourcemapMap.set(filename, map);
}
return code;
});
}
else {

@@ -41,0 +72,0 @@ const swcRegisterConfig = (0, read_default_tsconfig_1.tsCompilerOptionsToSwcConfig)(options, filename);

{
"name": "@swc-node/register",
"version": "1.5.8",
"version": "1.6.0",
"description": "SWC node register",

@@ -42,4 +42,4 @@ "keywords": [

"dependencies": {
"@swc-node/core": "^1.9.2",
"@swc-node/sourcemap-support": "^0.2.4",
"@swc-node/core": "^1.10.0",
"@swc-node/sourcemap-support": "^0.3.0",
"colorette": "^2.0.19",

@@ -55,3 +55,3 @@ "debug": "^4.3.4",

"devDependencies": {
"@swc/core": "^1.3.32",
"@swc/core": "^1.3.35",
"@swc/helpers": "^0.4.14",

@@ -74,5 +74,10 @@ "@types/debug": "^4.1.7",

},
"./register": "./lib/register.js"
"./register": {
"require": "./lib/register.js"
},
"./esm": {
"import": "./esm/esm.mjs"
}
},
"gitHead": "593ee50193c40a5805beda8fb35a597332fbb898"
"gitHead": "75d423ff1bc57f0422bff7443b762f6977878fb8"
}

@@ -76,2 +76,4 @@ # `@swc-node/register`

case ts.ScriptTarget.ES2020:
case ts.ScriptTarget.ES2021:
case ts.ScriptTarget.ES2022:
case ts.ScriptTarget.ESNext:

@@ -78,0 +80,0 @@ case ts.ScriptTarget.Latest:

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

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