codeflash-internal/.claude/rules/js-packages.md
Kevin Turcios d7a8b8f227
perf: fix CI build + lazy-load heavy libs + parallelize DB queries (#2601)
## Summary
- **Fix CI build failure**: Auth0Client crashes during Next.js
prerendering when env vars aren't set. Returns a no-op stub (`getSession
→ null`) when domain is missing — semantically correct for static
generation
- **Lazy-load markdown libs (~260kb)**: ReactMarkdown, remarkGfm, and
react-syntax-highlighter were eagerly imported in monaco-diff-viewer but
only rendered when user expands "Generated Tests". Extracted into a
dynamic component
- **Parallelize repo detail query**: `getRepositoryById` ran the
activity count sequentially after the repo lookup. Since `repoId` is
already available, all three queries now run in parallel

## Test plan
- [ ] CI `build` check passes (was failing since #2598)
- [ ] Trace page still renders generated tests correctly when expanded
- [ ] Repository detail page loads correctly with activity status
2026-04-13 11:03:05 -05:00

1.3 KiB

paths
js/**

JS/TS Packages

NEVER start, restart, or manage dev servers (pnpm dev, node, nohup, background processes). The developer will run services manually.

pnpm workspace at js/. Install from workspace root: cd js && pnpm install. All use ESLint + Prettier.

Prisma

Schema lives in common/prisma/schema.prisma, shared by cf-api and cf-webapp. pnpm's isolated node_modules means each package gets its own @prisma/client — no symlinks needed. common is CommonJS — use require-style imports when working with it directly. Published as @codeflash-ai/common to GitHub Packages; workspace packages reference it as "workspace:*".

Package Gotchas

cf-api

  • Webhook routes MUST be registered before body parser (raw body needed for signature verification)
  • instrument.ts must be imported first in entry point (Sentry init)
  • Tests use dependency injection: setXxxDependencies() / resetXxxDependencies()

VSC-Extension

  • Different prettier config: 80 width + semicolons (vs 100/no-semi elsewhere)
  • npm workspaces for local @codeflash/* packages
  • Sidebar is a separate Vite/React app embedded via webview postMessage
  • acquireVsCodeApi() called once per session — store and reuse
  • esbuild excludes vscode module (provided by runtime)