opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix: add TypeScript path mapping for workspace packages in development mode

Open Haadka opened this issue 5 months ago • 1 comments

Problem

On Windows 11, @opencode-ai/sdk package could not be resolved when running bun dev, causing the error:

error: Cannot find module '@opencode-ai/sdk' from 'packages/opencode/src/plugin/index.ts'

Solution

Added TypeScript path mapping to packages/opencode/tsconfig.json:

  • Added baseUrl and paths configuration
  • Maps @opencode-ai/sdk and @opencode-ai/plugin to their source TypeScript files
  • Only affects development mode with --conditions=development
  • Production builds continue to use the proper workspace package resolution

Testing

  • bun dev now starts successfully
  • ✅ Module imports resolve correctly in development
  • ✅ Production builds unaffected (uses dist/ files via package.json exports)
  • ✅ All typecheck tests pass

Changes

  • Modified packages/opencode/tsconfig.json to include path mapping for workspace packages
  • This is a development-only fix that maintains proper package abstractions

Haadka avatar Aug 07 '25 12:08 Haadka

curious why --conditions=development doesn't work?

thdxr avatar Aug 09 '25 00:08 thdxr