Skip to content

fix(build): make tsc build clean (49 errors → 0) - #106

Merged
vibe-dex merged 1 commit into
mainfrom
fix/build-typecheck-clean
May 1, 2026
Merged

vibe-dex merged 1 commit into
mainfrom
fix/build-typecheck-clean

Conversation

@vibe-dex

@vibe-dex vibe-dex commented May 1, 2026

Copy link
Copy Markdown
Contributor

Summary

`npm run build` and `npm run typecheck` were both exiting with code 2 on `main` due to 49 cumulative errors. Three independent issues; this PR fixes all three.

# Code Where Count Fix
1 TS5097 `scripts/**/*.ts` 47 Strip `.ts` extension from relative imports (same shape as consumer-facing #105, just for scripts). 80 imports across 34 files.
2 TS2322 `scripts/migrate/phase-analyze.ts:393` 1 `reExport` variable type didn't match `isReExport()`'s return type (`target: string | undefined` vs `target?: string`). Aligned them.
3 TS2493 `src/cms/sectionLoaders.test.ts:36` 1 `vi.fn(async (props) => ...)` typed the mock as 1-arg, but the test destructured `[calledProps, calledReq]`. Added `_req: Request` 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 (e.g. local prepublish smoke tests)
  • Made the typecheck signal worthless — "89 errors, all pre-existing" was a recurring false alarm during this week's plan work, leading to wasted re-verification each time

Verification

```
$ npm run build

@decocms/[email protected] build
tsc
$ echo $?
0

$ npm run typecheck

@decocms/[email protected] typecheck
tsc --noEmit
$ echo $?
0

$ npx vitest run
Test Files 9 passed (9)
Tests 104 passed (104)

$ head -2 dist/src/admin/meta.js
import { djb2Hex } from "../sdk/djb2";
import { composeMeta } from "./schema";
```

Scope

35 files, +85/-82 (~1-for-1 replacements). One method behind the scripts/ replace: a one-shot Node script that walks `scripts/**/.ts` and applies the regex `/(from\s+["'])(.[^"']).ts(["'])/g → $1$2$3`. Only matches relative imports ending in `.ts`. Doesn't touch package imports, `.json`/`.css` imports, or comments.

Test plan

  • CI passes (this is what `npm run check` exercises)
  • Sample migration script still runs end-to-end (`scripts/migrate.ts` is the published bin entry — no semantic change, but worth a smoke test before merge)
  • Verify `@decocms/[email protected]+1` publish output identical (only sources changed)

Made with Cursor

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
@vibe-dex
vibe-dex merged commit 2833d6e into main May 1, 2026
1 check passed
vibe-dex added a commit that referenced this pull request May 1, 2026
…checklist (#109)

Two stale areas in the deco-to-tanstack-migration skill, plus one
brand-new reference distilling battle-tested cleanup patterns.

## Changes

### `templates/vite-config.md` — drop ~80 lines of stub duplication

The old template inlined the entire `deco-server-only-stubs` plugin
(react-dom/server, node:async_hooks, node:stream, node:stream/web,
tanstack-head-scripts) — ~60 lines that exactly mirror what
`@decocms/start/vite`'s `decoVitePlugin()` already does.

The new template uses `decoVitePlugin()` and adds the production-grade
boilerplate that real sites actually need (and that the old version
omitted): VTEX dev proxy, CSP frame-ancestors header, build sourcemap,
PLUGIN_WARNING filter, react-compiler config, `pure: ["console.log"]`,
and the full `dedupe` list including `@decocms/start` + `@decocms/apps`.

### `references/vite-config/README.md` — fix "minimal" config that was broken

The "post-migration minimal config" was missing `decoVitePlugin()`
entirely. Without it, the client bundle crashes on transitively imported
server modules. Added the plugin + the minimum dedupe list, and
cross-referenced the full template.

### `references/post-migration-cleanup.md` — NEW

Dedicated reference distilling the cleanup work that surfaces on every
real migration:

1. Detect + delete unused `src/lib/*` shims (with a copy-paste detection
   script). Real-world data: baggagio-tanstack had 11 generated shims
   and 0 actual users; casaevideo had 11 generated and 1 used.
2. Drop the `site-manual-chunks` and `deco-stub-meta-gen` inline plugins
   that are now framework-provided in `@decocms/start >= 2.5.0`.
3. Drop the `runtime.ts` `invoke` shim — `@decocms/start/sdk` exports
   both `invoke` (singleton) and `createAppInvoke` (typed factory).
4. Drop site-local `withSiteGlobals` workaround — framework helper is
   now opt-in and tested.
5. Verify VTEX util imports point direct at `@decocms/apps/vtex/...`,
   not at dead `~/lib/vtex-*` shims (the migration script's stale
   `phase-cleanup.rewriteVtexUtilImports` was silently regressing
   them).
6. Search for orphan `TODO: move into framework` comments and either
   migrate, file an issue, or delete.

Plus a verification checklist.

## Why now

Validated in this session against three reference sites
(casaevideo-storefront, baggagio-tanstack, casaevideo). Each cleanup
step has a corresponding shipped or in-flight PR (#103/#106/#107/#108
on framework, #5/#6/#7 on baggagio-tanstack), so the checklist isn't
speculative.

## Scope discipline

This PR only edits skill content; no source/runtime changes. Both
`.agents/skills/` and `.cursor/skills/` copies stay in sync.

Made-with: Cursor
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant