mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 14:16:12 +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
|
||||
}
|
||||
}
|
||||
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 minify(code: Buffer, opts: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
||||
export function minifySync(code: Buffer, opts: Buffer): TransformOutput
|
||||
|
@ -5,9 +5,19 @@ const { platform, arch } = process
|
||||
|
||||
let nativeBinding = null
|
||||
let localFileExisted = false
|
||||
let isMusl = false
|
||||
let loadError = null
|
||||
|
||||
const isMusl = () => {
|
||||
try {
|
||||
const isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
|
||||
|
||||
return isMusl;
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch (platform) {
|
||||
case 'android':
|
||||
if (arch !== 'arm64') {
|
||||
@ -122,8 +132,7 @@ switch (platform) {
|
||||
case 'linux':
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
|
||||
if (isMusl) {
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'swc.linux-x64-musl.node')
|
||||
)
|
||||
@ -152,8 +161,7 @@ switch (platform) {
|
||||
}
|
||||
break
|
||||
case 'arm64':
|
||||
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
|
||||
if (isMusl) {
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'swc.linux-arm64-musl.node')
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user