Desktop ESM Import Resolution Fix
Summary
Fixed a desktop startup crash where Electron failed to load @islandflow/types with ERR_MODULE_NOT_FOUND for packages/types/src/events. The types package now uses explicit .ts relative imports, and desktop TypeScript build settings were updated to permit and rewrite those imports during emit.
Changes Made
- Updated all internal re-exports/imports in
packages/types/srcthat pointed to sibling modules without file extensions to use explicit.tsextensions. - Updated desktop TS compiler options in
apps/desktop/tsconfig.json:allowImportingTsExtensions: trueandrewriteRelativeImportExtensions: true. - Created and tracked the bug in Beads as
islandflow-64s.
Context
The desktop app launches via Electron (Node ESM behavior), while much of this monorepo is typically run through Bun. Bun accepts extensionless TypeScript relative imports that Node ESM does not. Since @islandflow/types exports source TS (./src/index.ts), Electron loaded those sources directly and failed on extensionless sibling imports.
Important Implementation Details
- The fix stays within current package structure; no new build pipeline was introduced for
@islandflow/types. - By enabling
rewriteRelativeImportExtensions, desktop emit remains compatible even while accepting.tsspecifiers during type-checking. - This avoids adding runtime Node flags and keeps behavior explicit in source and compiler config.
Relevant Diff Snippets
Unified patch snippets below are diffs.com-compatible patch text format.
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
-export * from "./events";
+export * from "./events.ts";
-export * from "./live";
+export * from "./live.ts";
...
diff --git a/apps/desktop/tsconfig.json b/apps/desktop/tsconfig.json
"noEmit": false,
+"allowImportingTsExtensions": true,
+"rewriteRelativeImportExtensions": true,
"sourceMap": true,
Expected Impact for End-Users
Desktop developers can run bun run dev:desktop without the startup crash. This unblocks local desktop testing and feature work without requiring manual runtime flags or ad hoc environment tweaks.
Validation
- Ran
bun --cwd=apps/desktop run buildsuccessfully. - Ran
node -e "import('./packages/types/src/index.ts')"to confirm direct source import resolution works after the import updates. - Ran
bun run dev:desktopand confirmed Electron launched successfully past the previous module-resolution failure (manually interrupted afterward).
Issues, Limitations, and Mitigations
- This fix assumes Node/Electron TypeScript type-stripping support remains available for direct TS source loading.
- The plugin catalog 403 warnings observed during launch are unrelated to this module-resolution fix and remain unchanged.
Follow-up Work
- Evaluate whether
@islandflow/typesshould eventually ship a dedicated built JS output for stricter runtime portability beyond Bun/Electron workflows. - Add a lightweight desktop smoke check in CI for startup-path regressions around workspace package resolution.
Beads issue: islandflow-64s.