fix(core): Core loads Node.js-only modules at import time and crashes browser bundles #89
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
qa:preview
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
quatrain/core#89
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
@quatrain/coreimportsnode-persist,node:child_processandwhichat module load (packages/core/src/Core.ts).Since
@quatrain/http1.0.6 depends on@quatrain/core(MessagePack normalizer, #82), every browser app using@quatrain/api-clientnow bundles Core. On load,which→isexereadsprocess.platformand the app crashes:Observed on a Vite-built backoffice (blank page).
Expected
Core must be importable in a browser. Node.js-only features (
Core.storage,execPromise,getSystemCommandPath) may fail when used there, but not at import time.Fix
Load these modules lazily on first use, with a regression test asserting none of them is evaluated when importing Core.
Follow-up (out of scope)
properties/HashProperty.tsimportsnode:cryptoat top level: Vite stubs it (fails on use), stricter bundlers (bun build --target=browser) refuse to build. Candidate for lazy loading or Web Crypto.