packages/* package.json main points at non-existent compiled .js #2

Open
opened 2026-06-14 23:51:58 +00:00 by forgejo-admin · 0 comments

Summary

The workspace packages declare "main": "./src/index.js" / "types": "./src/index.d.ts", but the source is TypeScript (src/index.ts) and there is no build step producing the .js/.d.ts. Anything that resolves these packages via Node/package.json main (rather than tsconfig path aliases) breaks.

Affected: packages/shared, packages/trpc-utils (and likely ui, auth-client — should audit all).

How it surfaced

The root tests/unit/shared.test.ts couldn't resolve @lunacycle/shared under vitest. The app vite configs resolve workspace aliases via nxViteTsPaths(), but the root vitest.config.ts didn't — so it fell back to node_modules resolution and hit the missing .js. Worked around in commit 4396221 by adding nxViteTsPaths() to vitest.config.ts.

Why it's worth fixing properly

The workaround papers over the root cause: the package manifests advertise an entry point that doesn't exist. Any consumer not going through the nx tsconfig-paths plugin (a new tool, a script, a different test runner) will hit the same wall.

Options

  1. Add a build step that emits dist/index.js + .d.ts and point main/types/exports there.
  2. Use an exports/imports map pointing at the .ts source (works for bun/vite-native consumers).
  3. Remove main/types and rely entirely on tsconfig path aliases (document that consumers must use them).

Acceptance criteria

  • Audit all packages/*/package.json entry-point fields.
  • Pick and apply a consistent resolution strategy.
  • @lunacycle/shared resolves without the vitest-specific plugin workaround (or we consciously keep it and document why).
## Summary The workspace packages declare `"main": "./src/index.js"` / `"types": "./src/index.d.ts"`, but the source is TypeScript (`src/index.ts`) and there is no build step producing the `.js`/`.d.ts`. Anything that resolves these packages via Node/package.json `main` (rather than tsconfig path aliases) breaks. Affected: `packages/shared`, `packages/trpc-utils` (and likely `ui`, `auth-client` — should audit all). ## How it surfaced The root `tests/unit/shared.test.ts` couldn't resolve `@lunacycle/shared` under vitest. The app vite configs resolve workspace aliases via `nxViteTsPaths()`, but the root `vitest.config.ts` didn't — so it fell back to `node_modules` resolution and hit the missing `.js`. Worked around in commit `4396221` by adding `nxViteTsPaths()` to `vitest.config.ts`. ## Why it's worth fixing properly The workaround papers over the root cause: the package manifests advertise an entry point that doesn't exist. Any consumer not going through the nx tsconfig-paths plugin (a new tool, a script, a different test runner) will hit the same wall. ## Options 1. Add a build step that emits `dist/index.js` + `.d.ts` and point `main`/`types`/`exports` there. 2. Use an `exports`/`imports` map pointing at the `.ts` source (works for bun/vite-native consumers). 3. Remove `main`/`types` and rely entirely on tsconfig path aliases (document that consumers must use them). ## Acceptance criteria - [ ] Audit all `packages/*/package.json` entry-point fields. - [ ] Pick and apply a consistent resolution strategy. - [ ] `@lunacycle/shared` resolves without the vitest-specific plugin workaround (or we consciously keep it and document why).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
celilo/lunacycle#2
No description provided.