Skip to content

fix: create dev shims in gateway build so workspace consumers resolve bun exports#425

Merged
BYK merged 1 commit into
mainfrom
fix/gateway-dev-shims
May 20, 2026
Merged

fix: create dev shims in gateway build so workspace consumers resolve bun exports#425
BYK merged 1 commit into
mainfrom
fix/gateway-dev-shims

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 20, 2026

Summary

Fixes the lore startup failure in OpenCode caused by PR #415Cannot find module '@loreai/gateway'.

PR #415 changed the gateway's "bun" export condition from ./src/index.ts (always present) to ./dist/index.bun.js (requires bun run bundle). A prepare script was added to create a dev shim, but Bun does not execute lifecycle scripts for workspace packages, so the file was never created.

Changes

  • packages/gateway/script/build.ts: Replace the no-op buildLibrary() with a function that creates lightweight dev shims (export * from "../src/index.ts") for dist/index.bun.js and dist/embedding-worker.js. Skips overwriting real bundle output by content-checking existing files.
  • packages/gateway/package.json: Remove the broken prepare script (never ran for workspace packages).
  • package.json (root): Add postinstall script that runs bun --filter '@loreai/gateway' build so bun install alone creates the dev shims.
  • packages/gateway/test/bundle-exports.test.ts: Update skip condition to detect dev shims vs real bundles so content-checking tests correctly skip in dev.

How it works

  • bun run build (workspace-wide) now creates dev shims for gateway's "bun" exports
  • bun run bundle (production) still wipes dist/ first and creates real artifacts — shims never interfere
  • Root postinstall ensures fresh clones + bun install have working exports immediately
  • .gitignore already excludes dist/, so shims aren't committed

… bun exports

PR #415 changed the gateway's "bun" export from ./src/index.ts to
./dist/index.bun.js, but that file only exists after `bun run bundle`.
The `prepare` script added to create a dev shim never ran because Bun
does not execute lifecycle scripts for workspace packages.

- Make buildLibrary() in build.ts create lightweight dev shims that
  re-export from source (export * from "../src/index.ts")
- Add root postinstall to run gateway build after `bun install`
- Remove the broken prepare script from gateway package.json
- Update bundle-exports test skip condition to detect dev shims
@BYK BYK self-assigned this May 20, 2026
@BYK BYK merged commit ada02c5 into main May 20, 2026
7 checks passed
@BYK BYK deleted the fix/gateway-dev-shims branch May 20, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant