fix(core): load Node.js-only dependencies lazily so Core runs in browsers (#89) #90
No reviewers
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!90
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/89-core-browser-safe-node-imports"
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?
Closes #89
Why
@quatrain/http1.0.6 now depends on@quatrain/core, so browser apps using@quatrain/api-clientbundle Core. Core importednode-persist,node:child_processandwhichat module load;isexe(viawhich) readsprocess.platformat evaluation →ReferenceError: process is not defined, blank page on a Vite-built backoffice.What
Core.ts: the three Node.js-only modules arerequire()d on first use and cached (Core.storagebecomes a getter;execPromiseandgetSystemCommandPathload on call). Types imported withimport type. Public API unchanged.Core.browser.test.ts: mocks the three modules to throw when evaluated, asserts that importing./Coreand./indexloads none of them, and that they load on first use. Fails on the previousCore.ts.Verification
npx jestinpackages/core: 119/119 passingtsc --noEmitcleanNot in this PR
properties/HashProperty.tsstill importsnode:cryptoat top level (see #89 follow-up).🤖 Generated with Claude Code