Repository navigation
fix(src): strip .ts extensions from internal imports for consumer typecheck - #105
Merged
Merged
Conversation
…echeck
@decocms/start publishes raw TypeScript source via package.json `exports`.
Consumers' bundlers (Vite, tsx) compile on the fly and don't care about
extensions, but consumer `tsc --noEmit` follows imports into
node_modules/@decocms/start/src/* and surfaces a hard error for any
import that ends with `.ts`:
error TS5097: An import path can only end with a '.ts' extension
when 'allowImportingTsExtensions' is enabled.
Forcing every consumer to enable allowImportingTsExtensions in their
tsconfig is awkward (it requires noEmit and limits other build flows).
The fix is to drop the redundant `.ts` extension on internal relative
imports in published source files. moduleResolution: "bundler" handles
extensionless paths cleanly; tsx and Vite do too.
Scope: src/ only. scripts/ retain `.ts` for now since they're not
published as importable modules — they run as bin scripts via tsx.
Files (20 imports across 7 files):
- src/admin/decofile.ts (3)
- src/admin/meta.ts (2)
- src/cms/loader.ts (1)
- src/daemon/fs.ts (1)
- src/daemon/index.ts (8)
- src/daemon/middleware.ts (4)
- src/sdk/cachedLoader.ts (1)
Verification:
- typecheck: TS5097 errors in src/ go from 20 → 0 (consumer-facing)
- vitest: 104/104 pass
- tsc emit: dist/src/admin/meta.js now reads `from "./schema"`
(previously `from "./schema.ts"` — caused downstream issues)
Diff is clean — 20 insertions / 20 deletions, just the imports. No
formatting changes.
Made-with: Cursor
|
🎉 This PR is included in version 2.4.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
3 tasks
vibe-dex
added a commit
that referenced
this pull request
May 1, 2026
Three independent issues that together broke `npm run build` on main: 1. **47× TS5097** in `scripts/**/*.ts` — relative imports ending in `.ts` (same shape as the consumer-facing fix in #105, just for scripts). Done with a one-shot regex replace: `from "./foo.ts"` → `from "./foo"`. 80 imports across 34 files; mechanical, no semantic change. 2. **TS2322** in `scripts/migrate/phase-analyze.ts:393` — `reExport` was declared as `{ is: false, target: undefined as string | undefined }` (target required) but `isReExport(content)` returns `{ is: boolean; target?: string }` (target optional). Aligned the variable type to the return type. 3. **TS2493** in `src/cms/sectionLoaders.test.ts:36` — `vi.fn(async (props) => props)` declared a 1-arg function, so `loader.mock.calls[0]` typed as a 1-tuple, but the test destructures `[calledProps, calledReq]`. Added the second `_req: Request` parameter to the mock signature. Why it was masked: The framework publishes raw TypeScript via `package.json` `exports` pointing at `./src/...` (verified — no `dist/` in the export map). Releases run `semantic-release` directly without `npm run build`, so the build break didn't gate publishing. But it polluted `npm run check`, broke `dist/` for anyone trying to use compiled output, and made the typecheck signal worthless ("89 errors, all pre-existing" was a recurring false alarm in this session). Verification: - `npm run build` exits 0 (was exit 2) - `npm run typecheck` exits 0 (was exit 2) - vitest: 104/104 pass - `dist/src/admin/meta.js` emits with extensionless imports Total: 35 files changed, +85/-82 (mostly 1-for-1 line replacements). Made-with: Cursor
2 of 3 tasks
vibe-dex
added a commit
that referenced
this pull request
May 1, 2026
…build) (#112) Adds a new Phase 8 to the migration pipeline that actually compiles the migrated site after bootstrap completes. This is the gate that catches regressions which slip past the static `phase-verify` checks — the same class of bugs we hit in #105 (TS5097, rewriter leaving `.ts` in import paths) and the dead `src/lib/*` shims that broke `phase-cleanup`. ## Behavior - Default: runs `npx tsc --noEmit`. Failures are warnings — migration completes, but the user sees the truncated diagnostic output. - `--strict`: failures abort the migration with exit code 2 so CI can fail the pipeline. - `--with-build`: also runs `npx vite build` after typecheck. Slower (~30-90s) but catches runtime-only issues. - `--no-compile`: skips the phase entirely. - Auto-skipped when `node_modules/` is missing (bootstrap likely failed). ## Implementation - `scripts/migrate/phase-compile.ts` — exports `compile(ctx, opts)`. Returns `{ shouldFail }` so the caller decides exit codes; we don't `process.exit` ourselves which keeps it unit-testable. The command runner is injectable via `opts.runner` for tests. - `scripts/migrate.ts` — wires three new flags (`--strict`, `--with-build`, `--no-compile`) through to the phase. Updated `--help` output. - `scripts/migrate/phase-compile.test.ts` — 11 tests covering dry-run, missing node_modules, success path, failure paths, strict promotion, build flag gating, and the truncate helper. - `.agents/skills/deco-migrate-script/SKILL.md` — documents the new phase, flags, and CI usage pattern (`--strict --with-build`). ## Validation - `npx vitest run` → 132 tests pass (was 121, +11 new) - `npm run typecheck` → clean Co-authored-by: Cursor <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
`@decocms/start` publishes raw TypeScript source via `package.json` `exports` (e.g. `"./admin": "./src/admin/index.ts"`). Consumers' bundlers (Vite, tsx) compile on the fly and don't care about extensions, but consumer `tsc --noEmit` follows imports into `node_modules/@decocms/start/src/*` and surfaces a hard error for any import that ends with `.ts`:
```
error TS5097: An import path can only end with a '.ts' extension
when 'allowImportingTsExtensions' is enabled.
```
Today, every consumer site (baggagio-tanstack, casaevideo-storefront, etc.) sees ~8 of these errors when they run `tsc --noEmit` — purely as a side effect of importing from this package. Forcing each consumer to enable `allowImportingTsExtensions` in their tsconfig is awkward (it requires `noEmit` and limits other build flows).
The fix is one-line per import: drop the redundant `.ts` extension on internal relative imports in published source files. `moduleResolution: "bundler"` handles extensionless paths cleanly; tsx and Vite do too.
Scope
`src/` only. `scripts/` retain `.ts` for now since they're not published as importable modules — they run as bin scripts via tsx.
Diff is exactly 20 insertions / 20 deletions — pure import path changes, no formatting noise.
Verification
Consumer impact: a baggagio-tanstack `npm run typecheck` should drop from
8 framework-induced TS5097 errors → 0 once a release ships with this fix.
Why not biome auto-format too
Running `biome check --write` on these files reformats line widths
(collapsing multi-line function calls), bloating the diff with
unrelated changes. Kept this PR strictly to the import path fix
for reviewability. Formatting can be a follow-up if desired.
Test plan
Made with Cursor