Make @knolo/core Expo-safe by splitting runtime and Node pack entrypoints#27
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0157e03ac3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -1,5 +1,5 @@ | |||
| // src/index.ts | |||
| export { mountPack, hasSemantic } from './pack.js'; | |||
| export { mountPack, hasSemantic } from './pack.runtime.js'; | |||
There was a problem hiding this comment.
Preserve Node path mounting on default core entry
Switching @knolo/core to export mountPack from pack.runtime removes filesystem-path support for Node callers that still import the default entry, so existing flows now fail at runtime when they pass local paths. I checked packages/cli/bin/knolo.mjs (cmdQuery uses core.mountPack({ src: packPath })) and both adapter constructors in packages/langchain/src/index.js and packages/llamaindex/src/index.js (mountPack({ src: this.packPath })), and these now hit the React Native URL-only error path instead of loading local files.
Useful? React with 👍 / 👎.
Motivation
node:*stdlib import that Metro still pulls into the bundle graph even when guarded at runtime.Description
packages/core/src/pack.runtime.ts) that uses onlyfetchfor string sources and exposes shared parsing helpers (mountPackFromBuffer,toArrayBuffer) andhasSemantic.packages/core/src/pack.node.ts) that re-uses the runtime parsing helpers and is the only place that dynamically importsnode:fs/promisesto support filesystem paths andfile://URLs.@knolo/coreexportsmountPack/types from the runtime-safe entry (src/index.ts->pack.runtime.js) and added a Node public entry@knolo/core/nodeviasrc/node.ts.package.jsonexports to include runtime conditions (react-native/browser) for the default entry and a./nodeexport for the Node-only build, added a small runtime guard script (scripts/check-runtime-no-node.mjs), adjusted tests to call the Node entry for filesystem mounts, and updated README docs with migration guidance.Testing
npm run test --workspace @knolo/core, which builds, runs the runtime-guard, and executes the package tests, and the suite completed successfully (All tests passed).dist/index.js,dist/index.d.ts,dist/node.js,dist/node.d.ts).packages/core/scripts/check-runtime-no-node.mjswas executed as part of the test run and confirmed there are nonode:fs,fs/promises, ornode:pathtokens in the runtime bundle.Codex Task