Skip to content

Make @knolo/core Expo-safe by splitting runtime and Node pack entrypoints#27

Merged
HiveForensicsAI merged 1 commit intomainfrom
codex/refactor-@knolo/core-for-expo-compatibility
Mar 1, 2026
Merged

Make @knolo/core Expo-safe by splitting runtime and Node pack entrypoints#27
HiveForensicsAI merged 1 commit intomainfrom
codex/refactor-@knolo/core-for-expo-compatibility

Conversation

@HiveForensicsAI
Copy link
Copy Markdown
Contributor

Motivation

  • Metro (Expo) fails because the runtime pack entry contained a node:* stdlib import that Metro still pulls into the bundle graph even when guarded at runtime.
  • The goal is to allow zero Node stdlib imports in the runtime/browser/React Native entry while keeping convenient Node-local-path mounting available for Node users.

Description

  • Split the pack implementation into a runtime-safe module (packages/core/src/pack.runtime.ts) that uses only fetch for string sources and exposes shared parsing helpers (mountPackFromBuffer, toArrayBuffer) and hasSemantic.
  • Added a Node-only module (packages/core/src/pack.node.ts) that re-uses the runtime parsing helpers and is the only place that dynamically imports node:fs/promises to support filesystem paths and file:// URLs.
  • Updated public entrypoints so the default @knolo/core exports mountPack/types from the runtime-safe entry (src/index.ts -> pack.runtime.js) and added a Node public entry @knolo/core/node via src/node.ts.
  • Updated package.json exports to include runtime conditions (react-native/browser) for the default entry and a ./node export 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

  • Ran the package test suite with 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).
  • Verified the dist output contains runtime and node artifacts via the build (dist/index.js, dist/index.d.ts, dist/node.js, dist/node.d.ts).
  • The runtime guard packages/core/scripts/check-runtime-no-node.mjs was executed as part of the test run and confirmed there are no node:fs, fs/promises, or node:path tokens in the runtime bundle.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@HiveForensicsAI HiveForensicsAI merged commit c11ff23 into main Mar 1, 2026
0 of 2 checks passed
@HiveForensicsAI HiveForensicsAI deleted the codex/refactor-@knolo/core-for-expo-compatibility branch March 1, 2026 15:26
@HiveForensicsAI HiveForensicsAI added enhancement New feature or request and removed codex labels Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants