fix(natives): detect compiled-binary mode via embedded-addon presence
Standalone Bun binaries on WSL (and any host where the user moves the
binary away from the build-host's checkout) failed to load
pi_natives.<platform>-<arch>*.node. The loader's isCompiledBinary
detection relied on two signals that are both false in shipped binaries:
process.env.PI_COMPILED (bun --define PI_COMPILED=true substitutes the
bare identifier, not property accesses on process.env) and
__filename.includes("$bunfs") (Bun retains the build-host absolute path
in __filename for required CJS modules — only import.meta.url is
rewritten). Detection therefore returned false, embedded-addon
extraction was skipped, and the only candidates probed were the
build-host nativeDir and execDir.
Make embedded-addon presence the authoritative compiled-mode signal
(it is null in the post-build --reset stub, populated when embed:native
ran for the standalone build), eagerly require the manifest, and
extract candidate-path computation into a pure helper covered by a
host-platform-agnostic unit test. Also fix the build-time --define so
process.env.PI_COMPILED is genuinely set at runtime as a defensive
fallback.
Fixes #823
This commit is contained in:
@@ -34,7 +34,7 @@ async function main(): Promise<void> {
|
||||
"build",
|
||||
"--compile",
|
||||
"--define",
|
||||
"PI_COMPILED=true",
|
||||
'process.env.PI_COMPILED="true"',
|
||||
"--external",
|
||||
"mupdf",
|
||||
"--root",
|
||||
|
||||
Reference in New Issue
Block a user