Repository navigation
Build: Build TypeScript types one project at a time in CI (wp/7.1) - #85772
Conversation
A single `tsc --build` type checks every project in one process, with several type checkers per project. With the native TypeScript compiler, this uses more memory than runners with fewer resources have, such as the standard runners used by private forks (2 vCPU, 8 GB), and the job is killed. In CI, build the projects one at a time in separate processes instead, in the same order a single `tsc --build` uses and with a single type checker. Each process reads the declaration files emitted by earlier ones rather than their sources, so peak memory is that of the largest project. Local builds are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Y86gzn3apHfS8kjjkmzTW
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
🤖 PR meta 🤖📦 Bundle sizeSize Change: 0 B Total Size: 7.75 MB
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
ramonjd
left a comment
There was a problem hiding this comment.
I'm not an expert in this area, but I ran the build locally.
Verified that the build order matches tsc --build --dry exactly (102 projects), and my macOS build drops from 550–673 s to 215 s.
What?
In CI, builds the TypeScript types on
wp/7.1one project at a time, with a single type checker, instead of in onetsc --buildfor all 102 projects. Local builds are unchanged.Why?
On this branch,
npm run buildtype checks with the native TypeScript compiler (TypeScript 7). A singletsc --buildchecks every project in one process, with several type checkers per project, and peaks above 7 GB.--max-old-space-sizedoesn't limit it, because it isn't a Node process.This issue can be encountered on runs with fewer resources, such as the standard runners used within private forks (2 vCPU, 8 GB RAM). The "Type checking" step runs out of memory and the job is killed, or it swaps until it times out. Runs on this repository's larger runners aren't affected.
Trunk and
wp/7.2avoid this differently, by splitting the tsconfigs and building declarations with--noCheck(#81499, #81839). Those changes are too large to backport to a release branch.How?
tools/build-scripts/packages/typescript-build-order.mjs: lists the projects in the order a singletsc --buildbuilds them: depth first through the roottsconfig.json's references, in listed order, each project after its references. Keeping that exact order matters, because some projects (such asstorybook) import packages without referencing them.tools/build-scripts/build.mjs: whenCIis set, runstsc --build <project> --checkers 1for each project in that order. Each process reads the declaration files emitted by earlier ones instead of their sources, so peak memory is that of the largest project rather than the whole graph. WithoutCI, it still runs a singletsc --build.@wordpress/build-scriptsis a private workspace, so this doesn't affect any published package.Testing Instructions
I measured
npm run buildinside a cgroup limited to 7 GB of RAM, no swap, and 2 CPUs (desrosj#854):tscprocesstsc --build(current)--builders 1 --checkers 1--checkers 1(this PR)components)--checkers 2The Static Analysis job on this PR checks that the build still type checks and leaves no local changes.
To test locally, run
CI=true npm run buildand check that it completes and thatgit statusis clean.🤖 Generated with Claude Code
https://claude.ai/code/session_011Y86gzn3apHfS8kjjkmzTW