Skip to content

improve(build): reuse tsdown declarations across full builds - #109737

Merged
steipete merged 1 commit into
mainfrom
codex/tsdown-build-reuse
Jul 17, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/tsdown-build-reuse

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Full builds rerun three expensive tsdown declaration graphs even when most or all inputs are unchanged. Measurements showed about 196 seconds of declaration work across the AI package, workspace packages, and unified core/plugin graph, while the runtime JavaScript build itself took about 4 seconds.

Why This Change Was Made

This adds content-addressed, module-level declaration reuse for the three independent tsdown build groups. Runtime JavaScript is still rebuilt every time. Each group restores only its own declaration outputs, validates an internal fingerprint, and reruns declarations when relevant source, tool, environment, or configuration inputs change.

Public full-build workflows persist the reusable payload with actions/cache, using exact content keys plus a coarse restore key. The internal group fingerprints make loose restores safe. Private-QA declaration output is deliberately excluded because the Actions cache namespace is not an authorization boundary.

The implementation also narrows tsdown cleanup to the selected group, keeps concurrent jobs isolated, rotates the cache key with an explicit version, and relies on GitHub cache quota/LRU eviction. Rolldown's upstream incremental build cache remains watch-process-only, so it cannot provide cross-job reuse: https://rolldown.rs/reference/InputOptions.experimental

User Impact

No product/runtime behavior change. Repeated full builds become materially faster. Partial changes invalidate only affected declaration groups: core/plugin changes preserve package caches; package changes conservatively invalidate dependent groups. Cold or unsupported builds behave as before.

Evidence

  • Final local full build: 93.86s cold, 19.80s exact warm (79% lower wall time).
  • Warm declaration inventory matched cold output exactly: 8,195 files, 19,211,247 bytes.
  • Persisted cache payload: 17 MB raw, about 2.29 MB gzip-compressed.
  • Representative Blacksmith prototype: 168.56s cold, 10.71s exact warm, 10.07s after an unrelated UI change.
  • Focused tests: 4 files, 260 passed, 1 skipped.
  • Script/test type checks, formatting, lint, and git diff --check: green.
  • Fresh autoreview: no accepted or actionable findings.

AI-assisted implementation and review.

@steipete
steipete requested a review from a team as a code owner July 17, 2026 06:53
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: L maintainer Maintainer-authored PR labels Jul 17, 2026

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

Copy link
Copy Markdown
Contributor

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: 016eb6372c

ℹ️ 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 scripts/build-all.mjs
cache: {
env: ["OPENCLAW_RUN_NODE_SKIP_DTS_BUILD"],
inputs: [...TSDOWN_DECLARATION_TOOL_INPUTS, "tsdown.config.ts", TSDOWN_PACKAGES_CACHE_INPUT],
outputs: declarationCacheOutputs(TSDOWN_MAIN_PACKAGE_OUTPUT_ROOTS),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Include web-content-core declarations in package cache

When a full build restores a fresh tsdown-packages cache, this step reruns tsdown with OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 and restores only TSDOWN_MAIN_PACKAGE_OUTPUT_ROOTS. That root list excludes packages/web-content-core/dist, even though tsdown.config.ts:570 builds that package and packages/web-content-core/package.json:11 exports ./dist/provider-runtime-shared.d.mts as its types entry, so warm CI/release builds from a clean runner can finish without that declaration file. Please add web-content-core to the restored declaration roots or otherwise cache/restore its dts before skipping declarations.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit d783961 into main Jul 17, 2026
138 of 144 checks passed
@steipete
steipete deleted the codex/tsdown-build-reuse branch July 17, 2026 07:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant