Repository navigation
Use the incremental build when from is set - #20688
Conversation
[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 |
|
No actionable comments were generated in the recent review. WalkthroughIncremental 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:
|
34f9d41 to
62dda3d
Compare
10a2675 to
b3c2738
Compare
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()`.
b3c2738 to
1a4475d
Compare
… 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.
This PR builds on #20680, and targets its branch. Merge that one first.
Summary
The incremental build of #20680 is turned off when
fromis set. The CLI with--output,@tailwindcss/postcss,@tailwindcss/webpack,@tailwindcss/turbopackand@tailwindcss/vitewith CSS source maps all setfrom, so they don't get the faster rebuilds.These integrations need
fromfor 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:@tailwind utilitiesbefore 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 afterbuild().Performance
Rebuilds on tailwindcss.com that add one class (median of 600 builds):
maincompile()withfrom(CLI with--output, webpack, Turbopack)compile()withfrom, and a source map after each build (CLI with--map, Vite)compileAst()withfrom(PostCSS, without its conversion to a PostCSS AST)With this PR, a build with
fromis 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.tsusedfromto 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 withoutfrom, and withfromit also compares the source maps. Without the fix, 7 tests fail.source-map.test.tsdoes several builds, and compares each source map with the source map of a new compiler. It fails when the positions are out of date.tailwindcss,@tailwindcss/postcssand@tailwindcss/nodetests pass.@tailwindcss/cliand@tailwindcss/postcss.Sent by an AI assistant on behalf of @RobinMalfait.