@swc/core
Advanced tools
Comparing version 1.7.18 to 1.7.19-nightly-20240828.1
@@ -5,77 +5,44 @@ /* auto-generated by NAPI-RS */ | ||
export class Compiler { | ||
constructor(); | ||
constructor() | ||
} | ||
export type JsCompiler = Compiler; | ||
export type JsCompiler = Compiler | ||
export function bundle( | ||
confItems: Buffer, | ||
signal?: AbortSignal | undefined | null | ||
): Promise<{ [index: string]: { code: string; map?: string } }>; | ||
export declare function bundle(confItems: Buffer, signal?: AbortSignal | undefined | null): Promise<{ [index: string]: { code: string, map?: string } }> | ||
export function getTargetTriple(): string; | ||
export declare function getTargetTriple(): string | ||
export function initCustomTraceSubscriber( | ||
traceOutFilePath?: string | undefined | null | ||
): void; | ||
export declare function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void | ||
export function minify( | ||
code: Buffer, | ||
opts: Buffer, | ||
signal?: AbortSignal | undefined | null | ||
): Promise<TransformOutput>; | ||
export declare function minify(code: Buffer, opts: Buffer, extras: NapiMinifyExtra, signal?: AbortSignal | undefined | null): Promise<TransformOutput> | ||
export function minifySync(code: Buffer, opts: Buffer): TransformOutput; | ||
export declare function minifySync(code: Buffer, opts: Buffer, extras: NapiMinifyExtra): TransformOutput | ||
export function parse( | ||
src: string, | ||
options: Buffer, | ||
filename?: string | undefined | null, | ||
signal?: AbortSignal | undefined | null | ||
): Promise<string>; | ||
export interface NapiMinifyExtra { | ||
mangleNameCache?: object | ||
} | ||
export function parseFile( | ||
path: string, | ||
options: Buffer, | ||
signal?: AbortSignal | undefined | null | ||
): Promise<string>; | ||
export declare function newMangleNameCache(): object | ||
export function parseFileSync(path: string, opts: Buffer): string; | ||
export declare function parse(src: string, options: Buffer, filename?: string | undefined | null, signal?: AbortSignal | undefined | null): Promise<string> | ||
export function parseSync( | ||
src: string, | ||
opts: Buffer, | ||
filename?: string | undefined | null | ||
): string; | ||
export declare function parseFile(path: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<string> | ||
export function print( | ||
programJson: string, | ||
options: Buffer, | ||
signal?: AbortSignal | undefined | null | ||
): Promise<TransformOutput>; | ||
export declare function parseFileSync(path: string, opts: Buffer): string | ||
export function printSync(program: string, options: Buffer): TransformOutput; | ||
export declare function parseSync(src: string, opts: Buffer, filename?: string | undefined | null): string | ||
export function transform( | ||
src: string, | ||
isModule: boolean, | ||
options: Buffer, | ||
signal?: AbortSignal | undefined | null | ||
): Promise<TransformOutput>; | ||
export declare function print(programJson: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput> | ||
export function transformFile( | ||
src: string, | ||
isModule: boolean, | ||
options: Buffer, | ||
signal?: AbortSignal | undefined | null | ||
): Promise<TransformOutput>; | ||
export declare function printSync(program: string, options: Buffer): TransformOutput | ||
export function transformFileSync( | ||
s: string, | ||
isModule: boolean, | ||
opts: Buffer | ||
): TransformOutput; | ||
export declare function transform(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput> | ||
export declare function transformFile(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput> | ||
export declare function transformFileSync(s: string, isModule: boolean, opts: Buffer): TransformOutput | ||
export interface TransformOutput { | ||
code: string; | ||
map?: string; | ||
code: string | ||
map?: string | ||
output?: string | ||
} | ||
@@ -85,10 +52,7 @@ | ||
export interface TransformOutput { | ||
code: string; | ||
map?: string; | ||
code: string | ||
map?: string | ||
} | ||
export function transformSync( | ||
s: string, | ||
isModule: boolean, | ||
opts: Buffer | ||
): TransformOutput; | ||
export declare function transformSync(s: string, isModule: boolean, opts: Buffer): TransformOutput | ||
642
binding.js
@@ -7,356 +7,350 @@ // prettier-ignore | ||
let nativeBinding = null; | ||
const loadErrors = []; | ||
let nativeBinding = null | ||
const loadErrors = [] | ||
const isMusl = () => { | ||
let musl = false; | ||
if (process.platform === "linux") { | ||
musl = isMuslFromFilesystem(); | ||
if (musl === null) { | ||
musl = isMuslFromReport(); | ||
} | ||
if (musl === null) { | ||
musl = isMuslFromChildProcess(); | ||
} | ||
let musl = false | ||
if (process.platform === 'linux') { | ||
musl = isMuslFromFilesystem() | ||
if (musl === null) { | ||
musl = isMuslFromReport() | ||
} | ||
return musl; | ||
}; | ||
if (musl === null) { | ||
musl = isMuslFromChildProcess() | ||
} | ||
} | ||
return musl | ||
} | ||
const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-"); | ||
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-') | ||
const isMuslFromFilesystem = () => { | ||
try { | ||
return readFileSync("/usr/bin/ldd", "utf-8").includes("musl"); | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
try { | ||
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl') | ||
} catch { | ||
return null | ||
} | ||
} | ||
const isMuslFromReport = () => { | ||
const report = | ||
typeof process.report.getReport === "function" | ||
? process.report.getReport() | ||
: null; | ||
if (!report) { | ||
return null; | ||
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null | ||
if (!report) { | ||
return null | ||
} | ||
if (report.header && report.header.glibcVersionRuntime) { | ||
return false | ||
} | ||
if (Array.isArray(report.sharedObjects)) { | ||
if (report.sharedObjects.some(isFileMusl)) { | ||
return true | ||
} | ||
if (report.header && report.header.glibcVersionRuntime) { | ||
return false; | ||
} | ||
return false | ||
} | ||
const isMuslFromChildProcess = () => { | ||
try { | ||
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl') | ||
} catch (e) { | ||
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false | ||
return false | ||
} | ||
} | ||
function requireNative() { | ||
if (process.platform === 'android') { | ||
if (process.arch === 'arm64') { | ||
try { | ||
return require('./swc.android-arm64.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-android-arm64') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else if (process.arch === 'arm') { | ||
try { | ||
return require('./swc.android-arm-eabi.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-android-arm-eabi') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else { | ||
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) | ||
} | ||
if (Array.isArray(report.sharedObjects)) { | ||
if (report.sharedObjects.some(isFileMusl)) { | ||
return true; | ||
} | ||
} else if (process.platform === 'win32') { | ||
if (process.arch === 'x64') { | ||
try { | ||
return require('./swc.win32-x64-msvc.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-win32-x64-msvc') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else if (process.arch === 'ia32') { | ||
try { | ||
return require('./swc.win32-ia32-msvc.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-win32-ia32-msvc') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else if (process.arch === 'arm64') { | ||
try { | ||
return require('./swc.win32-arm64-msvc.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-win32-arm64-msvc') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else { | ||
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) | ||
} | ||
return false; | ||
}; | ||
} else if (process.platform === 'darwin') { | ||
try { | ||
return require('./swc.darwin-universal.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-darwin-universal') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
const isMuslFromChildProcess = () => { | ||
try { | ||
return require("child_process") | ||
.execSync("ldd --version", { encoding: "utf8" }) | ||
.includes("musl"); | ||
} catch (e) { | ||
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false | ||
return false; | ||
if (process.arch === 'x64') { | ||
try { | ||
return require('./swc.darwin-x64.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-darwin-x64') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else if (process.arch === 'arm64') { | ||
try { | ||
return require('./swc.darwin-arm64.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-darwin-arm64') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else { | ||
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) | ||
} | ||
}; | ||
} else if (process.platform === 'freebsd') { | ||
if (process.arch === 'x64') { | ||
try { | ||
return require('./swc.freebsd-x64.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-freebsd-x64') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
function requireNative() { | ||
if (process.platform === "android") { | ||
if (process.arch === "arm64") { | ||
try { | ||
return require("./swc.android-arm64.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-android-arm64"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else if (process.arch === "arm") { | ||
try { | ||
return require("./swc.android-arm-eabi.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-android-arm-eabi"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else { | ||
loadErrors.push( | ||
new Error(`Unsupported architecture on Android ${process.arch}`) | ||
); | ||
} | ||
} else if (process.platform === "win32") { | ||
if (process.arch === "x64") { | ||
try { | ||
return require("./swc.win32-x64-msvc.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-win32-x64-msvc"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else if (process.arch === "ia32") { | ||
try { | ||
return require("./swc.win32-ia32-msvc.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-win32-ia32-msvc"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else if (process.arch === "arm64") { | ||
try { | ||
return require("./swc.win32-arm64-msvc.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-win32-arm64-msvc"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else { | ||
loadErrors.push( | ||
new Error( | ||
`Unsupported architecture on Windows: ${process.arch}` | ||
) | ||
); | ||
} | ||
} else if (process.platform === "darwin") { | ||
} else if (process.arch === 'arm64') { | ||
try { | ||
return require('./swc.freebsd-arm64.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-freebsd-arm64') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else { | ||
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) | ||
} | ||
} else if (process.platform === 'linux') { | ||
if (process.arch === 'x64') { | ||
if (isMusl()) { | ||
try { | ||
return require("./swc.darwin-universal.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
return require('./swc.linux-x64-musl.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-linux-x64-musl') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else { | ||
try { | ||
return require("@swc/core-darwin-universal"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
return require('./swc.linux-x64-gnu.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-linux-x64-gnu') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
if (process.arch === "x64") { | ||
try { | ||
return require("./swc.darwin-x64.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-darwin-x64"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else if (process.arch === "arm64") { | ||
try { | ||
return require("./swc.darwin-arm64.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-darwin-arm64"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else { | ||
loadErrors.push( | ||
new Error(`Unsupported architecture on macOS: ${process.arch}`) | ||
); | ||
} | ||
} else if (process.platform === "freebsd") { | ||
if (process.arch === "x64") { | ||
try { | ||
return require("./swc.freebsd-x64.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-freebsd-x64"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else if (process.arch === "arm64") { | ||
try { | ||
return require("./swc.freebsd-arm64.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-freebsd-arm64"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else { | ||
loadErrors.push( | ||
new Error( | ||
`Unsupported architecture on FreeBSD: ${process.arch}` | ||
) | ||
); | ||
} | ||
} else if (process.platform === "linux") { | ||
if (process.arch === "x64") { | ||
if (isMusl()) { | ||
try { | ||
return require("./swc.linux-x64-musl.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-linux-x64-musl"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else { | ||
try { | ||
return require("./swc.linux-x64-gnu.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-linux-x64-gnu"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} | ||
} else if (process.arch === "arm64") { | ||
if (isMusl()) { | ||
try { | ||
return require("./swc.linux-arm64-musl.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-linux-arm64-musl"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else { | ||
try { | ||
return require("./swc.linux-arm64-gnu.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-linux-arm64-gnu"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} | ||
} else if (process.arch === "arm") { | ||
try { | ||
return require("./swc.linux-arm-gnueabihf.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-linux-arm-gnueabihf"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else if (process.arch === "riscv64") { | ||
if (isMusl()) { | ||
try { | ||
return require("./swc.linux-riscv64-musl.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-linux-riscv64-musl"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else { | ||
try { | ||
return require("./swc.linux-riscv64-gnu.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-linux-riscv64-gnu"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} | ||
} else if (process.arch === "s390x") { | ||
try { | ||
return require("./swc.linux-s390x-gnu.node"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
try { | ||
return require("@swc/core-linux-s390x-gnu"); | ||
} catch (e) { | ||
loadErrors.push(e); | ||
} | ||
} else { | ||
loadErrors.push( | ||
new Error(`Unsupported architecture on Linux: ${process.arch}`) | ||
); | ||
} | ||
} | ||
} else if (process.arch === 'arm64') { | ||
if (isMusl()) { | ||
try { | ||
return require('./swc.linux-arm64-musl.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-linux-arm64-musl') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else { | ||
try { | ||
return require('./swc.linux-arm64-gnu.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-linux-arm64-gnu') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} | ||
} else if (process.arch === 'arm') { | ||
try { | ||
return require('./swc.linux-arm-gnueabihf.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-linux-arm-gnueabihf') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else if (process.arch === 'riscv64') { | ||
if (isMusl()) { | ||
try { | ||
return require('./swc.linux-riscv64-musl.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-linux-riscv64-musl') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else { | ||
try { | ||
return require('./swc.linux-riscv64-gnu.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-linux-riscv64-gnu') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} | ||
} else if (process.arch === 's390x') { | ||
try { | ||
return require('./swc.linux-s390x-gnu.node') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
try { | ||
return require('@swc/core-linux-s390x-gnu') | ||
} catch (e) { | ||
loadErrors.push(e) | ||
} | ||
} else { | ||
loadErrors.push( | ||
new Error( | ||
`Unsupported OS: ${process.platform}, architecture: ${process.arch}` | ||
) | ||
); | ||
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) | ||
} | ||
} else { | ||
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) | ||
} | ||
} | ||
nativeBinding = requireNative(); | ||
nativeBinding = requireNative() | ||
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { | ||
try { | ||
nativeBinding = require('./swc.wasi.cjs') | ||
} catch (err) { | ||
if (process.env.NAPI_RS_FORCE_WASI) { | ||
console.error(err) | ||
} | ||
} | ||
if (!nativeBinding) { | ||
try { | ||
nativeBinding = require("./swc.wasi.cjs"); | ||
nativeBinding = require('@swc/core-wasm32-wasi') | ||
} catch (err) { | ||
if (process.env.NAPI_RS_FORCE_WASI) { | ||
console.error(err); | ||
} | ||
if (process.env.NAPI_RS_FORCE_WASI) { | ||
console.error(err) | ||
} | ||
} | ||
if (!nativeBinding) { | ||
try { | ||
nativeBinding = require("@swc/core-wasm32-wasi"); | ||
} catch (err) { | ||
if (process.env.NAPI_RS_FORCE_WASI) { | ||
console.error(err); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (!nativeBinding) { | ||
if (loadErrors.length > 0) { | ||
// TODO Link to documentation with potential fixes | ||
// - The package owner could build/publish bindings for this arch | ||
// - The user may need to bundle the correct files | ||
// - The user may need to re-install node_modules to get new packages | ||
throw new Error("Failed to load native binding", { cause: loadErrors }); | ||
} | ||
throw new Error(`Failed to load native binding`); | ||
if (loadErrors.length > 0) { | ||
// TODO Link to documentation with potential fixes | ||
// - The package owner could build/publish bindings for this arch | ||
// - The user may need to bundle the correct files | ||
// - The user may need to re-install node_modules to get new packages | ||
throw new Error('Failed to load native binding', { cause: loadErrors }) | ||
} | ||
throw new Error(`Failed to load native binding`) | ||
} | ||
module.exports.Compiler = nativeBinding.Compiler; | ||
module.exports.JsCompiler = nativeBinding.JsCompiler; | ||
module.exports.bundle = nativeBinding.bundle; | ||
module.exports.getTargetTriple = nativeBinding.getTargetTriple; | ||
module.exports.initCustomTraceSubscriber = | ||
nativeBinding.initCustomTraceSubscriber; | ||
module.exports.minify = nativeBinding.minify; | ||
module.exports.minifySync = nativeBinding.minifySync; | ||
module.exports.parse = nativeBinding.parse; | ||
module.exports.parseFile = nativeBinding.parseFile; | ||
module.exports.parseFileSync = nativeBinding.parseFileSync; | ||
module.exports.parseSync = nativeBinding.parseSync; | ||
module.exports.print = nativeBinding.print; | ||
module.exports.printSync = nativeBinding.printSync; | ||
module.exports.transform = nativeBinding.transform; | ||
module.exports.transformFile = nativeBinding.transformFile; | ||
module.exports.transformFileSync = nativeBinding.transformFileSync; | ||
module.exports.transformSync = nativeBinding.transformSync; | ||
module.exports.Compiler = nativeBinding.Compiler | ||
module.exports.JsCompiler = nativeBinding.JsCompiler | ||
module.exports.bundle = nativeBinding.bundle | ||
module.exports.getTargetTriple = nativeBinding.getTargetTriple | ||
module.exports.initCustomTraceSubscriber = nativeBinding.initCustomTraceSubscriber | ||
module.exports.minify = nativeBinding.minify | ||
module.exports.minifySync = nativeBinding.minifySync | ||
module.exports.newMangleNameCache = nativeBinding.newMangleNameCache | ||
module.exports.parse = nativeBinding.parse | ||
module.exports.parseFile = nativeBinding.parseFile | ||
module.exports.parseFileSync = nativeBinding.parseFileSync | ||
module.exports.parseSync = nativeBinding.parseSync | ||
module.exports.print = nativeBinding.print | ||
module.exports.printSync = nativeBinding.printSync | ||
module.exports.transform = nativeBinding.transform | ||
module.exports.transformFile = nativeBinding.transformFile | ||
module.exports.transformFileSync = nativeBinding.transformFileSync | ||
module.exports.transformSync = nativeBinding.transformSync |
import type { Plugin, ParseOptions, Module, Output, Options, Script, Program, JsMinifyOptions } from "@swc/types"; | ||
export type * from "@swc/types"; | ||
export { newMangleNameCache as experimental_newMangleNameCache } from "./binding"; | ||
import { BundleInput } from "./spack"; | ||
import type { NapiMinifyExtra } from "../binding"; | ||
/** | ||
@@ -14,4 +16,4 @@ * Version of the swc binding. | ||
private fallbackBindingsPluginWarningDisplayed; | ||
minify(src: string, opts?: JsMinifyOptions): Promise<Output>; | ||
minifySync(src: string, opts?: JsMinifyOptions): Output; | ||
minify(src: string, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Promise<Output>; | ||
minifySync(src: string, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Output; | ||
/** | ||
@@ -82,4 +84,4 @@ * @deprecated Use Rust instead. | ||
}>; | ||
export declare function minify(src: string, opts?: JsMinifyOptions): Promise<Output>; | ||
export declare function minifySync(src: string, opts?: JsMinifyOptions): Output; | ||
export declare function minify(src: string, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Promise<Output>; | ||
export declare function minifySync(src: string, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Output; | ||
/** | ||
@@ -86,0 +88,0 @@ * Configure custom trace configuration runs for a process lifecycle. |
21
index.js
@@ -46,4 +46,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT_EXTENSIONS = exports.getBinaryMetadata = exports.__experimental_registerGlobalTraceConfig = exports.minifySync = exports.minify = exports.bundle = exports.transformFileSync = exports.transformFile = exports.transformSync = exports.transform = exports.printSync = exports.print = exports.parseFileSync = exports.parseFile = exports.parseSync = exports.parse = exports.Compiler = exports.plugins = exports.version = void 0; | ||
exports.DEFAULT_EXTENSIONS = exports.getBinaryMetadata = exports.__experimental_registerGlobalTraceConfig = exports.minifySync = exports.minify = exports.bundle = exports.transformFileSync = exports.transformFile = exports.transformSync = exports.transform = exports.printSync = exports.print = exports.parseFileSync = exports.parseFile = exports.parseSync = exports.parse = exports.Compiler = exports.plugins = exports.version = exports.experimental_newMangleNameCache = void 0; | ||
const path_1 = require("path"); | ||
// @ts-ignore | ||
var binding_1 = require("./binding"); | ||
Object.defineProperty(exports, "experimental_newMangleNameCache", { enumerable: true, get: function () { return binding_1.newMangleNameCache; } }); | ||
const spack_1 = require("./spack"); | ||
@@ -96,6 +99,6 @@ const assert = __importStar(require("assert")); | ||
} | ||
minify(src, opts) { | ||
minify(src, opts, extras) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (bindings) { | ||
return bindings.minify(toBuffer(src), toBuffer(opts !== null && opts !== void 0 ? opts : {})); | ||
return bindings.minify(toBuffer(src), toBuffer(opts !== null && opts !== void 0 ? opts : {}), extras !== null && extras !== void 0 ? extras : {}); | ||
} | ||
@@ -108,5 +111,5 @@ else if (fallbackBindings) { | ||
} | ||
minifySync(src, opts) { | ||
minifySync(src, opts, extras) { | ||
if (bindings) { | ||
return bindings.minifySync(toBuffer(src), toBuffer(opts !== null && opts !== void 0 ? opts : {})); | ||
return bindings.minifySync(toBuffer(src), toBuffer(opts !== null && opts !== void 0 ? opts : {}), extras !== null && extras !== void 0 ? extras : {}); | ||
} | ||
@@ -374,10 +377,10 @@ else if (fallbackBindings) { | ||
exports.bundle = bundle; | ||
function minify(src, opts) { | ||
function minify(src, opts, extras) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return compiler.minify(src, opts); | ||
return compiler.minify(src, opts, extras); | ||
}); | ||
} | ||
exports.minify = minify; | ||
function minifySync(src, opts) { | ||
return compiler.minifySync(src, opts); | ||
function minifySync(src, opts, extras) { | ||
return compiler.minifySync(src, opts, extras); | ||
} | ||
@@ -384,0 +387,0 @@ exports.minifySync = minifySync; |
{ | ||
"name": "@swc/core", | ||
"version": "1.7.18", | ||
"version": "1.7.19-nightly-20240828.1", | ||
"description": "Super-fast alternative for babel", | ||
@@ -103,13 +103,13 @@ "homepage": "https://swc.rs", | ||
"optionalDependencies": { | ||
"@swc/core-darwin-x64": "1.7.18", | ||
"@swc/core-win32-x64-msvc": "1.7.18", | ||
"@swc/core-linux-x64-gnu": "1.7.18", | ||
"@swc/core-linux-x64-musl": "1.7.18", | ||
"@swc/core-win32-ia32-msvc": "1.7.18", | ||
"@swc/core-linux-arm-gnueabihf": "1.7.18", | ||
"@swc/core-linux-arm64-gnu": "1.7.18", | ||
"@swc/core-darwin-arm64": "1.7.18", | ||
"@swc/core-linux-arm64-musl": "1.7.18", | ||
"@swc/core-win32-arm64-msvc": "1.7.18" | ||
"@swc/core-darwin-x64": "1.7.19-nightly-20240828.1", | ||
"@swc/core-win32-x64-msvc": "1.7.19-nightly-20240828.1", | ||
"@swc/core-linux-x64-gnu": "1.7.19-nightly-20240828.1", | ||
"@swc/core-linux-x64-musl": "1.7.19-nightly-20240828.1", | ||
"@swc/core-win32-ia32-msvc": "1.7.19-nightly-20240828.1", | ||
"@swc/core-linux-arm-gnueabihf": "1.7.19-nightly-20240828.1", | ||
"@swc/core-linux-arm64-gnu": "1.7.19-nightly-20240828.1", | ||
"@swc/core-darwin-arm64": "1.7.19-nightly-20240828.1", | ||
"@swc/core-linux-arm64-musl": "1.7.19-nightly-20240828.1", | ||
"@swc/core-win32-arm64-msvc": "1.7.19-nightly-20240828.1" | ||
} | ||
} |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
119003
2946
1