Repository navigation
build: Parallelize Hey API and declaration emit, make edit linear - #132
Merged
Merged
Conversation
The build took about 48 s. Most of it went to three places: - describe-valibot-schemas spent 13 s in `edit`, which rebuilt the 2.6 MB valibot.gen.ts once per edit, about 6,500 times. `edit` now builds the result in one pass. - `tsc --emitDeclarationOnly` took 30 s, mostly checking the Valibot and Zod schemas, which import nothing else from src/. lib/emit-declarations.mjs emits from tsconfig.json in three worker threads: Valibot, Zod, and the rest. They run alongside the esbuild bundles. - Hey API took 5.4 s. The validator plugins read nothing the TypeScript and SDK plugins write, so lib/hey-api.mjs runs the three plugin groups in worker threads; each produces the same files as the combined run. src/ is byte-identical to main's. In dist/, only valibot.gen.d.ts and zod.gen.d.ts change, and only in the order of union members and enum keys: TypeScript orders them by when it first created each literal type, which depends on what else is in the program. Co-Authored-By: BYK <burak.kaya@sentry.io>
sentry-junior
Bot
requested review from
BYK,
MathurAditya724 and
betegon
as code owners
November 5, 2026 13:26
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9183811. Configure here.
tsc reports file names with forward slashes on Windows, so the grouped Valibot and Zod files also landed in the rest program and were emitted twice. Compare resolved paths, and fail when a group names a file that tsconfig.json does not include.
BYK
approved these changes
Nov 5, 2026
2 tasks done
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.

Follow-up to your approval comment on #131 ("see if we can benefit from any parallelization or optimizations in Hey API code"). This cuts
pnpm buildfrom about 48 s to about 25 s in my sandbox (4 vCPUs).Where the time went (on
main)createClientscripts/tsc --emitDeclarationOnlyWhat changes
editis linear:describe-valibot-schemasspent 13 s of the 14.6 s step phase inlib/generated-source.mjs'sedit. It sliced the whole 2.6 MBvalibot.gen.tsonce per edit, about 6,500 times.editnow builds the result in one pass.test/generated-source.test.tscovers both.tsc --emitDeclarationOnlyspent 25 of its 30 s checking, mostly on the Valibot and Zod schemas. Neither of those files imports anything else fromsrc/.lib/emit-declarations.mjsreadstsconfig.jsonand builds three programs in worker threads: Valibot, Zod, and everything else.lib/hey-api.mjsruns the three plugin groups in worker threads.src/.describeNullableValues,validatorOptions) moves frombuild.mjsinto this module.Output
src/is byte-identical tomain's.dist/, onlyvalibot.gen.d.tsandzod.gen.d.tschange, and only in the order of union members and enum keys. For example,"GET" | "HEAD" | "OPTIONS" | …becomes"GET" | "POST" | "HEAD" | …. TypeScript orders unions by when it first created each literal type, and that depends on what else is in the program. The types themselves don't change. Every other.d.tsfile is byte-identical.Cost
Peak memory of the build process goes from about 1.4 GB (plus the separate
tscprocess, about 1.6 GB) to about 2.3 GB in one process.Verification
pnpm buildpasses.pnpm typecheckpasses, and so do all 635 tests inpnpm test.diff -ragainstmain's build,src/is byte-identical. Indist/, only the two files above differ.--
View Session in Sentry