@swc-node/register
Advanced tools
Comparing version 1.9.0 to 1.9.1
import * as ts from 'typescript'; | ||
export declare const AVAILABLE_TS_EXTENSION_PATTERN: RegExp; | ||
export declare const AVAILABLE_EXTENSION_PATTERN: RegExp; | ||
export declare function compile(sourcecode: string, filename: string, options: ts.CompilerOptions & { | ||
@@ -3,0 +5,0 @@ fallbackToTs?: (filename: string) => boolean; |
@@ -26,5 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.register = exports.compile = void 0; | ||
const os_1 = require("os"); | ||
const path_1 = require("path"); | ||
exports.register = exports.compile = exports.AVAILABLE_EXTENSION_PATTERN = exports.AVAILABLE_TS_EXTENSION_PATTERN = void 0; | ||
const core_1 = require("@swc-node/core"); | ||
@@ -35,4 +33,16 @@ const sourcemap_support_1 = require("@swc-node/sourcemap-support"); | ||
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)(); | ||
const DEFAULT_EXTENSIONS = [ | ||
ts.Extension.Js, | ||
ts.Extension.Ts, | ||
ts.Extension.Jsx, | ||
ts.Extension.Tsx, | ||
ts.Extension.Mjs, | ||
ts.Extension.Mts, | ||
ts.Extension.Cjs, | ||
ts.Extension.Cts, | ||
'.es6', | ||
'.es', | ||
]; | ||
exports.AVAILABLE_TS_EXTENSION_PATTERN = new RegExp(`(?<!\\.d(${[ts.Extension.Ts, ts.Extension.Tsx, ts.Extension.Mts, ts.Extension.Cts].map((ext) => ext.replace(/^\./, '\\.')).join('|')}))$`, 'i'); | ||
exports.AVAILABLE_EXTENSION_PATTERN = new RegExp(`(?<!\\.d(${DEFAULT_EXTENSIONS.map((ext) => ext.replace(/^\./, '\\.')).join('|')}))$`, 'i'); | ||
const injectInlineSourceMap = ({ filename, code, map, }) => { | ||
@@ -48,14 +58,6 @@ if (map) { | ||
function compile(sourcecode, filename, options, async = false) { | ||
if (filename.endsWith('.d.ts')) { | ||
return ''; | ||
if ((filename.includes('node_modules') && !exports.AVAILABLE_TS_EXTENSION_PATTERN.test(filename)) || | ||
!exports.AVAILABLE_EXTENSION_PATTERN.test(filename)) { | ||
return sourcecode; | ||
} | ||
if (options.files && options.files.length) { | ||
if (PLATFORM === 'win32' && | ||
options.files.every((file) => filename !== (0, path_1.resolve)(process.cwd(), file))) { | ||
return sourcecode; | ||
} | ||
if (PLATFORM !== 'win32' && options.files.every((file) => !filename.endsWith(file))) { | ||
return sourcecode; | ||
} | ||
} | ||
if (options && typeof options.fallbackToTs === 'function' && options.fallbackToTs(filename)) { | ||
@@ -62,0 +64,0 @@ delete options.fallbackToTs; |
{ | ||
"name": "@swc-node/register", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"description": "SWC node register", | ||
@@ -43,3 +43,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@swc-node/core": "^1.13.0", | ||
"@swc-node/core": "^1.13.1", | ||
"@swc-node/sourcemap-support": "^0.5.0", | ||
@@ -52,12 +52,12 @@ "colorette": "^2.0.20", | ||
"peerDependencies": { | ||
"@swc/core": ">= 1.3", | ||
"@swc/core": ">= 1.4.13", | ||
"typescript": ">= 4.3" | ||
}, | ||
"devDependencies": { | ||
"@swc/core": "^1.3.107", | ||
"@swc/helpers": "^0.5.3", | ||
"@swc/core": "^1.4.17", | ||
"@swc/helpers": "^0.5.11", | ||
"@types/debug": "^4.1.12", | ||
"lodash": "^4.17.21", | ||
"sinon": "^17.0.1", | ||
"typescript": "^5.3.3" | ||
"typescript": "^5.4.5" | ||
}, | ||
@@ -85,3 +85,3 @@ "funding": { | ||
}, | ||
"gitHead": "abfb35770bd952fb902ac698668874512e88460d" | ||
"gitHead": "c78ca5eadc24ec5c496d3d299ed1fd98da1ee6fb" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
96962
26
455
Updated@swc-node/core@^1.13.1