Skip to content

feat: incremental building - #1211

Open
avivkeller wants to merge 1 commit into
mainfrom
feat/experimental-incremental
Open

avivkeller wants to merge 1 commit into
mainfrom
feat/experimental-incremental

Conversation

@avivkeller

@avivkeller avivkeller commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

This adds --experimental-incremental to doc-kit generate. With it on, a build reuses what the previous build produced and only redoes what changed. Unchanged output files aren't rewritten, and files whose sources are gone are removed.

ast, metadata, jsx-ast and json keep each file's result under <output>/.doc-kit/, keyed by a hash of the item and the generator's configuration, and only process the files whose key changed. A result built from a reused one is keyed by that result's key rather than its content, and the output is identical to a full build. html re-renders a page when its jsx-ast output changes, or when something every page shares does (the component library, client assets, template or html configuration). all.html re-renders whenever a page in it does.

Generators opt in through a new third argument to generate (incremental.reuse and incremental.partition), documented in docs/creating-generators.md. With the option off, every item is treated as stale, so generators don't need a separate code path. Custom bundlers can return emitted from buildClient so that client files a later build stops writing get removed.

Benchmarks

The Node.js API docs (70 files) on an M5 with 4 threads, median of 3 runs:

-t html -t json
Without the option 10.6 s 4.4 s
First incremental build 11.1 s 4.8 s
Nothing changed 1.7 s 0.8 s
One file edited 4.0 s 1.1 s

An unchanged html build still bundles the library and client and compiles every page. After an edit, most of the time goes to re-rendering all.html.

node scripts/benchmark-incremental.mjs -i "../node/doc/api/*.md" -t html -t json

@avivkeller
avivkeller requested a review from a team as a code owner October 31, 2026 16:15
@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
api-docs-tooling Ready Ready Preview Nov 28, 2026 10:22pm UTC

Request Review

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ defddab 2026-11-28T22:22:30.590Z View logs ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 352352d 2026-11-28T18:32:43.871Z View logs ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 48fb2ea 2026-10-31T16:14:49.171Z View logs ↗

@avivkeller avivkeller changed the title åfeat: incremental building feat: incremental building Oct 31, 2026
@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.43295% with 158 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.00%. Comparing base (3d1c428) to head (defddab).

Files with missing lines Patch % Lines
scripts/benchmark-incremental.mjs 0.00% 121 Missing ⚠️
packages/core/src/incremental/section.mjs 96.87% 13 Missing ⚠️
packages/core/src/generators/metadata/generate.mjs 35.29% 11 Missing ⚠️
packages/cli/bin/commands/generate.mjs 0.00% 5 Missing ⚠️
packages/core/src/incremental/hash.mjs 95.78% 3 Missing and 1 partial ⚠️
packages/core/src/incremental/manifest.mjs 97.63% 3 Missing ⚠️
...ages/core/src/incremental/__tests__/index.test.mjs 99.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1211      +/-   ##
==========================================
+ Coverage   93.99%   94.00%   +0.01%     
==========================================
  Files         301      310       +9     
  Lines       31520    33552    +2032     
  Branches     3216     3403     +187     
==========================================
+ Hits        29627    31542    +1915     
- Misses       1871     1986     +115     
- Partials       22       24       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

api-links Generator

Performance estimate (single CI run)

  • Generation time: 25.0% faster (1.00 s → 750.00 ms)
  • Peak memory: 3.2% higher (268.43 MB → 276.91 MB)

json Generator

Performance estimate (single CI run)

  • Generation time: 10.3% faster (9.22 s → 8.27 s)
  • Peak memory: 4.7% lower (876.40 MB → 835.31 MB)

legacy-html Generator

Performance estimate (single CI run)

  • Generation time: 12.5% slower (14.93 s → 16.80 s)
  • Peak memory: 0.2% lower (1.36 GB → 1.36 GB)

legacy-json Generator

Performance estimate (single CI run)

  • Generation time: 7.1% faster (6.45 s → 5.99 s)
  • Peak memory: 8.8% lower (892.93 MB → 814.55 MB)

llms-txt Generator

Performance estimate (single CI run)

  • Generation time: 55.8% slower (5.11 s → 7.96 s)
  • Peak memory: 13.6% lower (952.15 MB → 822.63 MB)

orama-db Generator

Performance estimate (single CI run)

  • Generation time: 5.0% slower (8.16 s → 8.57 s)
  • Peak memory: 7.4% lower (1.02 GB → 970.96 MB)

web Generator

Performance estimate (single CI run)

  • Generation time: 1.2% faster (16.66 s → 16.46 s)
  • Peak memory: 0.8% lower (1.70 GB → 1.69 GB)

@ovflowd ovflowd 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.

Left a round of review comments. But cool stuff so far ;)

Also please add benchmarks and e2e tests!

Comment thread packages/core/src/incremental/index.mjs Resolved
Comment thread packages/core/src/incremental/index.mjs Resolved
Comment thread packages/core/src/utils/file.mjs Resolved
Comment thread packages/react/src/html/index.mjs Resolved
@bmuenzenmeyer

Copy link
Copy Markdown
Contributor

@avivkeller how does this relate to #1010

@ovflowd

ovflowd commented Nov 28, 2026

Copy link
Copy Markdown
Member

@bmuenzenmeyer I believe #1010 was the old version of this PR

This branch was successfully deployed

1 active deployment
Preview – api-docs-tooling — defddab4 Deployed Nov 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants