Skip to content

Build: Build TypeScript types one project at a time in CI (wp/7.1) - #85772

Merged
desrosj merged 1 commit into
wp/7.1from
fix/wp-7.1-type-build-memory
Oct 28, 2026
Merged

desrosj merged 1 commit into
wp/7.1from
fix/wp-7.1-type-build-memory

Conversation

@desrosj

@desrosj desrosj commented Oct 27, 2026

Copy link
Copy Markdown
Member

What?

In CI, builds the TypeScript types on wp/7.1 one project at a time, with a single type checker, instead of in one tsc --build for all 102 projects. Local builds are unchanged.

Why?

On this branch, npm run build type checks with the native TypeScript compiler (TypeScript 7). A single tsc --build checks every project in one process, with several type checkers per project, and peaks above 7 GB. --max-old-space-size doesn'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.2 avoid 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 single tsc --build builds them: depth first through the root tsconfig.json's references, in listed order, each project after its references. Keeping that exact order matters, because some projects (such as storybook) import packages without referencing them.
  • tools/build-scripts/build.mjs: when CI is set, runs tsc --build <project> --checkers 1 for 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. Without CI, it still runs a single tsc --build.

@wordpress/build-scripts is a private workspace, so this doesn't affect any published package.

Testing Instructions

I measured npm run build inside a cgroup limited to 7 GB of RAM, no swap, and 2 CPUs (desrosj#854):

Strategy Result Peak memory Largest tsc process Type build
Single tsc --build (current) killed 7 GB (limit) n/a n/a
Single, --builders 1 --checkers 1 passed 6.25 GB 6.1 GB 92 s
One project at a time, --checkers 1 (this PR) passed 5.6 GB 5.2 GB (components) 139 s
Batches of 5, --checkers 2 killed 7 GB (limit) n/a n/a

The 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 build and check that it completes and that git status is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_011Y86gzn3apHfS8kjjkmzTW

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
@desrosj desrosj self-assigned this Oct 27, 2026
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 79028f97-111f-410a-8475-66aaffc4e9ac

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

📦 Bundle size

Size Change: 0 B

Total Size: 7.75 MB

76b2cd9 Run

@desrosj
desrosj marked this pull request as ready for review October 27, 2026 20:35
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

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.

Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@desrosj
desrosj marked this pull request as draft October 27, 2026 20:37
@desrosj desrosj moved this from Backlog to In review in WordPress Project Build Tooling Oct 27, 2026
@desrosj desrosj added the [Type] Build Tooling Issues or PRs related to build tooling label Oct 27, 2026
@desrosj
desrosj marked this pull request as ready for review October 27, 2026 20:42
@desrosj
desrosj added this pull request to stack #85784 October 27, 2026 20:50

@ramonjd ramonjd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@desrosj
desrosj merged commit 81d272e into wp/7.1 Oct 28, 2026
91 of 97 checks passed
@desrosj
desrosj deleted the fix/wp-7.1-type-build-memory branch October 28, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Build Tooling Issues or PRs related to build tooling

Projects

Development

Successfully merging this pull request may close these issues.

2 participants