Skip to content

Use the incremental build when from is set - #20688

Merged
RobinMalfait merged 3 commits into
mainfrom
robin/review-pr-20680
Nov 10, 2026
Merged

RobinMalfait merged 3 commits into
mainfrom
robin/review-pr-20680

Conversation

@RobinMalfait

Copy link
Copy Markdown
Contributor

This PR builds on #20680, and targets its branch. Merge that one first.

Summary

The incremental build of #20680 is turned off when from is set. The CLI with --output, @tailwindcss/postcss, @tailwindcss/webpack, @tailwindcss/turbopack and @tailwindcss/vite with CSS source maps all set from, so they don't get the faster rebuilds.

These integrations need from for source maps, and for the file, line and column in CSS syntax errors (#19282). So the fix is in core, and the integrations don't change:

  • The incremental build gives new utility nodes the source location of @tailwind utilities before it caches them, the same way the non-incremental build does.
  • build() no longer tracks the positions in the output, so it can reuse the printed CSS of the cached utilities. buildSourceMap() tracks them instead, once for each build. The printed CSS is the same, and all callers ask for the source map right after build().

Performance

Rebuilds on tailwindcss.com that add one class (median of 600 builds):

Build main #20680 This PR
compile() with from (CLI with --output, webpack, Turbopack) 11.8 ms 11.8 ms 1.2–1.5 ms
compile() with from, and a source map after each build (CLI with --map, Vite) 18.4 ms 17.4 ms 7.4–8.8 ms
compileAst() with from (PostCSS, without its conversion to a PostCSS AST) 11.4 ms — 1.7 ms

With this PR, a build with from is as fast as a build without it (about 1.1 ms). With source maps, createSourceMap() is now most of the time.

Test plan

  • incremental.test.ts used from to get the non-incremental build to compare against. It now loads a second copy of the modules where the incremental build is mocked away. It runs with and without from, and with from it also compares the source maps. Without the fix, 7 tests fail.
  • A new test in source-map.test.ts does several builds, and compares each source map with the source map of a new compiler. It fails when the positions are out of date.
  • The tailwindcss, @tailwindcss/postcss and @tailwindcss/node tests pass.
  • Locally, the integration tests pass for Vite source maps, and for the watch mode, source map and parse error tests of @tailwindcss/cli and @tailwindcss/postcss.

Sent by an AI assistant on behalf of @RobinMalfait.

@RobinMalfait
RobinMalfait marked this pull request as ready for review November 10, 2026 14:38
@RobinMalfait
RobinMalfait requested a review from a team as a code owner November 10, 2026 14:38
@greptile-apps

greptile-apps Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Reviews (2) · Last reviewed commit: "Add a changelog entry for the incrementa..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Incremental builds now run when a utilities node exists, including when a source path is provided. The incremental builder can propagate source information to compiled nodes. CSS builds omit source-map positions, and source-map generation adds them when the tracked AST changes. Tests compare incremental output and source maps with fresh compiler results.

Merge Risk: Minimal · up to 10a26

The reviewed changes have no identified merge-blocking issue; merge after normal checks.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly summarizes the main change: enabling incremental builds when from is set.
Description check Passed The description explains the incremental-build change, its source-map handling, performance results, and tests.
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.
  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5e078064-0924-49c2-b487-c14b580c5613
Commits

Reviewing files that changed from the base of the PR and between 884f10d and 10a2675.

Files selected for processing: 5

  • .changelog/incremental-builds-with-from.md
  • packages/tailwindcss/src/incremental.test.ts
  • packages/tailwindcss/src/incremental.ts
  • packages/tailwindcss/src/index.ts
  • packages/tailwindcss/src/source-maps/source-map.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

@RobinMalfait
RobinMalfait force-pushed the incremental-utility-builds branch from 34f9d41 to 62dda3d Compare November 10, 2026 17:35
Base automatically changed from incremental-utility-builds to main November 10, 2026 18:03
The CLI with `--output`, webpack, Turbopack, PostCSS and Vite with source
maps all set `from`. They need it for source maps, and for the file
location in CSS syntax errors. So they couldn't use the incremental build.

The incremental build now gives new utility nodes the source location of
`@tailwind utilities` before they are flattened and cached, the same way
the non-incremental build does.

The tests used `from` to get the non-incremental build to compare
against. They now load a second copy of the modules where the incremental
build is turned off, and also compare the source maps with `from`.
With `from`, `build()` tracked the position of each node in the output,
for `buildSourceMap()`. Tracking can't use the printed CSS of the cached
utilities, so the CLI with `--output`, webpack and Turbopack paid for it
on each rebuild, also without a source map.

`buildSourceMap()` now prints the AST again with tracking, but only once
for each build. The printed CSS is the same, so the positions match the
output of `build()`. All callers ask for the source map right after
`build()`.
@RobinMalfait
RobinMalfait removed this pull request from stack #20689 November 10, 2026 18:12
@RobinMalfait
RobinMalfait merged commit fecba57 into main Nov 10, 2026
13 checks passed
@RobinMalfait
RobinMalfait deleted the robin/review-pr-20680 branch November 10, 2026 18:13
RobinMalfait added a commit that referenced this pull request Nov 16, 2026
… act on (#20728)

This PR keeps `### Changed` in the changelog for changes that users may
have to act on, and documents which section to use.

`[Unreleased]` had a `### Changed` section with two performance entries
(#20680 and
#20688). A performance
improvement is not a change that users have to act on, and the repo
already lists them under `### Fixed` (e.g.
#20694,
#20678 and
#20663).

## Changes

- `CHANGELOG.md`: remove the `### Changed` section of `[Unreleased]`.
Combine the two entries into one entry in `### Fixed`, because
#20688 only extends
#20680 to the other
integrations. The entry goes in the merge order of
#20680.
- `CHANGELOG.md`: move the canonicalization entry of
#20697 from `### Added`
to `### Fixed`, in merge order, and drop the empty `### Added` heading.
A canonicalization improvement is not a new feature for users, and the
canonicalization entries of 4.3.4 and 4.3.5 are in `### Fixed` too.
- `.github/CONTRIBUTING.md`: add a guide on which section to pick. The
examples for `### Changed` come from earlier releases: changes to the
CSS of existing utilities, renamed or replaced utilities (also when the
upgrade tool migrates them), theme defaults, APIs, stricter parsing,
source detection defaults, and supported versions.
- `.changelog/README.md`: link to that guide.

This PR edits `CHANGELOG.md` directly instead of adding a fragment,
because it fixes entries that the "Compile changelog" workflow already
compiled. Released sections stay as they are. The PR changes only docs,
so it needs no changelog entry of its own.

## Test plan

- `pnpm changelog check` passes.
- `pnpm --silent changelog` shows `[Unreleased]` with only `### Fixed`.
- `pnpm prettier --check` passes for the three files.
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.

1 participant