Skip to content

fix(build): reduce turbo cache invalidation fanout#2538

Merged
Yradex merged 5 commits intolynx-family:mainfrom
colinaaa:build/turbo-cache-fanout
Apr 29, 2026
Merged

fix(build): reduce turbo cache invalidation fanout#2538
Yradex merged 5 commits intolynx-family:mainfrom
colinaaa:build/turbo-cache-fanout

Conversation

@colinaaa
Copy link
Copy Markdown
Collaborator

@colinaaa colinaaa commented Apr 29, 2026

Summary

  • move shared Turbo invalidation onto globalDependencies and trim redundant //#build edges so unrelated edits stop fanning out across the build graph
  • build the web rsbuild plugin loader outputs, make @lynx-js/web-explorer#build depend on //#build, and hash the web plugin config so clean CI jobs do not consume missing or stale workspace artifacts
  • add the remaining missing rslib.config.ts inputs across Turbo-managed rslib packages, plus referenced helper files such as loaders/** and tsconfig.build.json, so config-only edits cannot replay stale cached outputs

Test Plan

  • NODE_OPTIONS=\"--max-old-space-size=32768\" pnpm turbo build --summarize --output-logs=none
  • NODE_OPTIONS=\"--max-old-space-size=32768\" pnpm turbo build --filter=@lynx-js/gesture-runtime --force --summarize --output-logs=none
  • NODE_OPTIONS=\"--max-old-space-size=32768\" pnpm turbo build --filter=@lynx-js/gesture-runtime --summarize --output-logs=none
  • NODE_OPTIONS=\"--max-old-space-size=32768\" pnpm turbo build --filter=@lynx-js/motion --force --summarize --output-logs=none
  • NODE_OPTIONS=\"--max-old-space-size=32768\" pnpm turbo build --filter=@lynx-js/motion --summarize --output-logs=none
  • pnpm turbo build --filter @lynx-js/web-platform-rsbuild-plugin --summarize
  • pnpm turbo build --filter @lynx-js/web-platform-rsbuild-plugin --dry=json
  • pnpm turbo build --filter @lynx-js/web-explorer --force --summarize after removing dist/ and *.tsbuildinfo for web-core, web-elements, web-worker-rpc, and web-explorer
  • local audit confirms every Turbo-managed package with rslib.config.ts now covers that config file in build.inputs, with extra helper files included where rslib.config.ts reaches outside src/**

Summary by CodeRabbit

  • Documentation

    • Added build cache and invalidation guidelines documentation for improved cache management.
  • Chores

    • Updated build task configurations across packages to properly track configuration file changes and refine dependency tracking, ensuring more accurate build cache invalidation and preventing stale builds.

Move shared builds away from repo-scoped //#build dependencies so unrelated website edits stop invalidating unrelated packages. Document the guardrails and verification trail for future Turbo config changes.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 29, 2026

⚠️ No Changeset found

Latest commit: 6fdf5d3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e9574430-f338-4a82-8f24-87d8a7753567

📥 Commits

Reviewing files that changed from the base of the PR and between 87a4acd and 6fdf5d3.

📒 Files selected for processing (7)
  • .github/turbo-cache.instructions.md
  • packages/react/refresh/turbo.json
  • packages/react/testing-library/turbo.json
  • packages/rspeedy/create-rspeedy/turbo.json
  • packages/rspeedy/plugin-qrcode/turbo.json
  • packages/rspeedy/plugin-react/turbo.json
  • packages/rspeedy/upgrade-rspeedy/turbo.json
✅ Files skipped from review due to trivial changes (7)
  • packages/rspeedy/upgrade-rspeedy/turbo.json
  • packages/react/testing-library/turbo.json
  • packages/rspeedy/plugin-react/turbo.json
  • packages/react/refresh/turbo.json
  • packages/rspeedy/create-rspeedy/turbo.json
  • .github/turbo-cache.instructions.md
  • packages/rspeedy/plugin-qrcode/turbo.json

📝 Walkthrough

Walkthrough

Adds Turbo cache/invalidation guidance; removes repo-scoped //#build dependencies from several package build tasks; adds root tsconfig.json to globalDependencies and clears //#build task inputs; updates web-rsbuild plugin build config, package script, and several package task inputs/dependsOn.

Changes

Cohort / File(s) Summary
Repo docs
\.github/turbo-cache.instructions.md
Adds Turbo cache and invalidation guidelines: prefer targeted/globalDependencies, avoid repo-wide //#build globs, require explicit dependsOn and include non-source config files in task inputs.
Root Turbo config
turbo.json
Adds tsconfig.json to globalDependencies, removes //#build from top-level build.dependsOn, and clears file-input globs from internal //#build task.
Package-level dependsOn removals
packages/lynx/gesture-runtime/turbo.jsonc, packages/motion/turbo.jsonc
Removed //#build from package build.dependsOn, leaving ^build.
Package-level dependsOn additions
packages/web-platform/web-explorer/turbo.json
Adds explicit tasks.build.dependsOn = ["//#build","^build"].
Package task inputs expanded to include configs
packages/web-platform/web-rsbuild-plugin/turbo.json, packages/react/refresh/turbo.json, packages/react/testing-library/turbo.json, packages/rspeedy/create-rspeedy/turbo.json, packages/rspeedy/plugin-qrcode/turbo.json, packages/rspeedy/plugin-react/turbo.json, packages/rspeedy/upgrade-rspeedy/turbo.json
Adds configuration files (e.g., rslib.config.ts, tsconfig*.json, package.json, loaders/**, types/**) to tasks.build.inputs so config-only edits invalidate cache as intended.
web-rsbuild-plugin build config & script
packages/web-platform/web-rsbuild-plugin/package.json, packages/web-platform/web-rsbuild-plugin/rslib.config.ts
Adds build npm script (rslib build) and changes rslib output config to two explicit ESM library builds with adjusted declaration emission and entry points.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

framework:React

Suggested reviewers

  • HuJean
  • PupilTong
  • upupming
  • Sherry-hue
  • Yradex

Poem

🐰 I hopped through configs, nudged a few,
Cleared wide globs so caches chew true,
Split outputs, added a build command,
Small tidy hops across the land,
Now builds purr soft — a carrot in hand.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(build): reduce turbo cache invalidation fanout' directly and clearly summarizes the main change: optimizing Turbo cache invalidation by reducing unnecessary fanout across the build graph.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b520637b53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web-platform/web-rsbuild-plugin/package.json
Make web-explorer wait for the root TypeScript outputs it consumes and include rsbuild-plugin config files in the Turbo hash so clean CI jobs and config-only edits cannot reuse stale artifacts.
Add missing rslib-related files to package build inputs so config-only edits cannot replay stale cached artifacts across the remaining Turbo-managed rslib packages.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6fdf5d3032

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread turbo.json
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 29, 2026

Merging this PR will not alter performance

✅ 81 untouched benchmarks
⏩ 26 skipped benchmarks1


Comparing colinaaa:build/turbo-cache-fanout (6fdf5d3) with main (e4ace87)

Open in CodSpeed

Footnotes

  1. 26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 29, 2026

React External

#823 Bundle Size — 680.27KiB (-0.02%).

6fdf5d3(current) vs caadd3b main#818(baseline)

Bundle metrics  Change 1 change
                 Current
#823
     Baseline
#818
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 39.71% 39.7%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 8.59% 8.59%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#823
     Baseline
#818
Improvement  Other 680.27KiB (-0.02%) 680.41KiB

Bundle analysis reportBranch colinaaa:build/turbo-cache-fanou...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 29, 2026

Web Explorer

#9281 Bundle Size — 900.02KiB (0%).

6fdf5d3(current) vs caadd3b main#9275(baseline)

Bundle metrics  Change 2 changes
                 Current
#9281
     Baseline
#9275
No change  Initial JS 44.46KiB 44.46KiB
No change  Initial CSS 2.22KiB 2.22KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 9 9
No change  Assets 11 11
Change  Modules 227(-1.3%) 230
No change  Duplicate Modules 11 11
Change  Duplicate Code 27.29%(+0.04%) 27.28%
No change  Packages 10 10
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#9281
     Baseline
#9275
No change  JS 495.88KiB 495.88KiB
No change  Other 401.92KiB 401.92KiB
No change  CSS 2.22KiB 2.22KiB

Bundle analysis reportBranch colinaaa:build/turbo-cache-fanou...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 29, 2026

React MTF Example

#840 Bundle Size — 196.54KiB (-0.02%).

6fdf5d3(current) vs caadd3b main#834(baseline)

Bundle metrics  Change 3 changes
                 Current
#840
     Baseline
#834
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 43.42% 43.4%
No change  Chunks 0 0
No change  Assets 3 3
Change  Modules 173(-0.57%) 174
No change  Duplicate Modules 66 66
Change  Duplicate Code 44.08%(+0.09%) 44.04%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#840
     Baseline
#834
No change  IMG 111.23KiB 111.23KiB
Improvement  Other 85.31KiB (-0.05%) 85.35KiB

Bundle analysis reportBranch colinaaa:build/turbo-cache-fanou...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 29, 2026

React Example

#7708 Bundle Size — 225.38KiB (-0.02%).

6fdf5d3(current) vs caadd3b main#7702(baseline)

Bundle metrics  Change 3 changes
                 Current
#7708
     Baseline
#7702
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 35.34% 35.33%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 179(-0.56%) 180
No change  Duplicate Modules 69 69
Change  Duplicate Code 44.57%(+0.07%) 44.54%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#7708
     Baseline
#7702
No change  IMG 145.76KiB 145.76KiB
Improvement  Other 79.63KiB (-0.05%) 79.67KiB

Bundle analysis reportBranch colinaaa:build/turbo-cache-fanou...Project dashboard


Generated by RelativeCIDocumentationReport issue

@Yradex Yradex merged commit eb46fea into lynx-family:main Apr 29, 2026
105 of 112 checks passed
upupming added a commit that referenced this pull request Apr 29, 2026
PR #2538 dropped `//#build` from `build.dependsOn`. `//#build` runs
`tsc --build`, which produces composite-project `lib/` outputs that
several workspace packages declare as their public types
(`@lynx-js/rspeedy` → `./lib/index.d.ts`, etc.).

`//#build` still runs as part of `pnpm turbo build` (no filter), but
now in parallel with package builds. Two packages whose `tsgo` dts
generation imports types from `lib/` race against `//#build`:

- `@lynx-js/config-rsbuild-plugin` → imports `@lynx-js/rspeedy`,
  `@lynx-js/template-webpack-plugin`
- `@lynx-js/reactlynx-testing-library` → imports `@lynx-js/rspeedy`

When the race is lost, builds fail with `TS2307: Cannot find module …`.
Add `//#build` to those two packages' own `dependsOn` (rather than the
global `build.dependsOn`) so they wait for `tsc --build` without
re-introducing the cache fanout #2538 was avoiding.

Verified: `find packages -name "*.tsbuildinfo" -delete && find packages
-type d -name lib -exec rm -rf {} + && pnpm turbo build --force`
succeeds end-to-end (49/49 tasks).
HuJean pushed a commit that referenced this pull request Apr 30, 2026
## Summary

[#2538](#2538) dropped
`//#build` from `build.dependsOn` to reduce cache fanout. `//#build`
runs the root `tsc --build`, which produces the composite-project `lib/`
outputs that several workspace packages declare as their public types:

- `@lynx-js/rspeedy` → `"types": "./lib/index.d.ts"`
- `@lynx-js/template-webpack-plugin`,
`@lynx-js/web-rsbuild-server-middleware`, etc.

`//#build` still runs as part of `pnpm turbo build` (no filter), but now
in parallel with package builds. Two packages whose `tsgo` dts
generation imports types from those `lib/` outputs race against
`//#build`:

- `@lynx-js/config-rsbuild-plugin` (imports `@lynx-js/rspeedy`,
`@lynx-js/template-webpack-plugin` in `LynxConfigWebpackPlugin.ts` /
`pluginLynxConfig.ts`)
- `@lynx-js/reactlynx-testing-library` (imports `@lynx-js/rspeedy` in
`rstest-config.ts`)

When the race is lost, those builds fail with `TS2307: Cannot find
module …`. This was hit on PR #2543 ([build / Build
(Ubuntu)](https://github.com/lynx-family/lynx-stack/actions/runs/25103126514/job/73557596812)
— same failure on Windows).

## Fix

Add `//#build` to the `dependsOn` of just the two affected packages (not
to the global `build.dependsOn`) so they wait for `tsc --build` without
re-introducing the cache fanout #2538 was avoiding.

## Test plan

- [x] ```bash
  find packages -name "*.tsbuildinfo" -delete
  find packages -type d -name lib -exec rm -rf {} +
  pnpm turbo build --force
  ```
succeeds end-to-end (49/49 tasks). On `main` (without this fix) the same
command fails on `@lynx-js/config-rsbuild-plugin#build` and
`@lynx-js/reactlynx-testing-library#build`.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Resolved TypeScript type resolution failures in clean CI/build
environments.

* **Chores**
* Ensured root composite build runs before package builds to enforce
correct build ordering and artifact availability.
* Added build configuration for a new extractor package and updated
package build dependencies.

* **Documentation**
* Clarified maintenance guidance for produced/generated build artifacts
and cache outputs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants