mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
fix(node-swc): Recover from ldd not found
This commit is contained in:
parent
1e5bc88cd3
commit
1dfc2ee105
4
node-swc/src/binding.d.ts
vendored
4
node-swc/src/binding.d.ts
vendored
@ -9,10 +9,6 @@ export class ExternalObject<T> {
|
|||||||
[K: symbol]: T
|
[K: symbol]: T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export interface TransformOutput {
|
|
||||||
code: string
|
|
||||||
map?: string | undefined | null
|
|
||||||
}
|
|
||||||
export function bundle(confItems: Buffer, signal?: AbortSignal | undefined | null): Promise<{ [index: string]: { code: string, map?: string } }>
|
export function bundle(confItems: Buffer, signal?: AbortSignal | undefined | null): Promise<{ [index: string]: { code: string, map?: string } }>
|
||||||
export function minify(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
export function minify(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||||
export function minifySync(code: Buffer, opts: Buffer): TransformOutput
|
export function minifySync(code: Buffer, opts: Buffer): TransformOutput
|
||||||
|
@ -5,9 +5,19 @@ const { platform, arch } = process
|
|||||||
|
|
||||||
let nativeBinding = null
|
let nativeBinding = null
|
||||||
let localFileExisted = false
|
let localFileExisted = false
|
||||||
let isMusl = false
|
|
||||||
let loadError = null
|
let loadError = null
|
||||||
|
|
||||||
|
const isMusl = () => {
|
||||||
|
try {
|
||||||
|
const isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
|
||||||
|
|
||||||
|
return isMusl;
|
||||||
|
} catch(e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case 'android':
|
case 'android':
|
||||||
if (arch !== 'arm64') {
|
if (arch !== 'arm64') {
|
||||||
@ -122,8 +132,7 @@ switch (platform) {
|
|||||||
case 'linux':
|
case 'linux':
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
case 'x64':
|
case 'x64':
|
||||||
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
|
if (isMusl()) {
|
||||||
if (isMusl) {
|
|
||||||
localFileExisted = existsSync(
|
localFileExisted = existsSync(
|
||||||
join(__dirname, 'swc.linux-x64-musl.node')
|
join(__dirname, 'swc.linux-x64-musl.node')
|
||||||
)
|
)
|
||||||
@ -152,8 +161,7 @@ switch (platform) {
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'arm64':
|
case 'arm64':
|
||||||
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
|
if (isMusl()) {
|
||||||
if (isMusl) {
|
|
||||||
localFileExisted = existsSync(
|
localFileExisted = existsSync(
|
||||||
join(__dirname, 'swc.linux-arm64-musl.node')
|
join(__dirname, 'swc.linux-arm64-musl.node')
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user