fix(build): emit package declarations with a blocking tsc pass#503
fix(build): emit package declarations with a blocking tsc pass#503FSM1 wants to merge 2 commits into
Conversation
The desktop-e2e "Build API" step intermittently fails on Windows with "Could not find a declaration file for module '@cipherbox/core' / '@cipherbox/sdk-core'", and a plain rerun usually goes green. Root cause: the workspace packages build with tsup using dts:true, which runs declaration emit as a separate pass concurrent with the JS emit. On Windows CI that dts worker intermittently fails to write index.d.ts (file locking / AV scan / timing on a freshly cleaned dist), yet tsup still exits 0. The dist ends up with index.js but no index.d.ts, so the frontend build step passes while the downstream API typecheck (nest build = tsc) then can't find the declarations. It is a silent build bug, not a test-timing flake. Fix: stop relying on tsup's concurrent dts. Set dts:false and emit declarations in a separate, blocking tsc pass via a new tsconfig.build.json in each package (build: "tsup && tsc -p tsconfig.build.json"). tsc runs after tsup and exits non-zero on any emit failure, so a JS-only dist can no longer slip through with exit 0. Applied to all five tsup-built packages (crypto, core, api-client, sdk-core, sdk) since they share the failure mode. Verified locally: all five packages emit dist/index.d.ts; sdk, api (nest build) and web (tsc -b) all typecheck clean against the new declarations. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Entire-Checkpoint: ddf895c9175f
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (13)
WalkthroughAcross four monorepo packages ( ChangesDeclaration Build Pipeline Refactor
Release Version Bumps
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: dependency version conflict. Check your lock file or package.json. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Release Preview
Cascade Details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #503 +/- ##
==========================================
+ Coverage 63.80% 63.90% +0.10%
==========================================
Files 140 141 +1
Lines 10633 10863 +230
Branches 1175 1205 +30
==========================================
+ Hits 6784 6942 +158
- Misses 3610 3678 +68
- Partials 239 243 +4
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Problem
The
Desktop E2E (windows)job intermittently fails at the Build API step with:A plain rerun usually goes green, so it reads as flaky — but it is a silent build bug, not test timing.
Root cause
The workspace packages build with
tsupusingdts: true, which runs declaration emit as a separate pass concurrent with the JS emit. Withclean: true, dist is wiped first, thenindex.js(fast esbuild pass) andindex.d.ts(slow rollup-dts worker) race into the same dir. On Windows CI the dts worker intermittently fails to writeindex.d.ts(file locking / AV scan / timing) — yettsupstill exits 0.The smoking gun in the failing run:
Build desktop frontend✓ passed (it runs thetsuppackage builds) whileBuild API✗ failed on the missing declarations. So tsup left an incomplete dist (index.js, noindex.d.ts) and exited 0; the downstreamnest build(tsc) then couldn't find the types. Bothcoreandsdk-coreshow up becausesdk-core's dts pass depends oncore's emitted types.Fix
Stop relying on tsup's fragile concurrent dts. In each tsup-built package:
tsup.config.ts:dts: falsepackage.json:"build": "tsup && tsc -p tsconfig.build.json"tsconfig.build.json:emitDeclarationOnly: true(test files excluded)tscruns after tsup and exits non-zero on any emit failure, so a JS-only dist can no longer slip through with exit 0 — the flake becomes impossible rather than rare.Applied to all five tsup-built packages (
crypto,core,api-client,sdk-core,sdk) since they share the identical failure mode; fixing only the two that failed today would leave the same latent flake in the rest.Verification (local)
dist/index.d.ts.@cipherbox/sdkbuild (consumes the other four) — clean.@cipherbox/apinest build(the exact failing CI step) — clean.@cipherbox/webtsc -b— clean.🤖 Generated with Claude Code
Summary by CodeRabbit