PostCSS: Fix Turbopack 'one-revision-behind' bug#17554
Conversation
c4b7d02 to 9ea4c49 Compare | I'm not sure if this is directly related to this issue, but after updating to Tailwind v4.1.3 which includes this change, I'm still not seeing changes reflected on each hot reload (but sometimes it works!), forcing me to restart my dev server for simple className changes in any context. For some reason Tailwind isn't picking up on new utilities being used. I haven't fully pinned down the cases where it's happening, but it's difficult to reproduce reliably. Most recently, I changed the ordering inside a // before <div className={cn("bg-white", className, getMyClassnames(props))} /> // after <div className={cn("bg-black", getMyClassnames(props), className)} />No hot reload and no update after a hard refresh, but after restarting the dev server, my change looked correct. Note that Environment:
Overall things are working fine. If upgrading Vite or Turbo is necessary to squash some of this behavior, happy to do it, but it may be quite a lift for us depending on how smoothly that goes. |
…minor) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@tailwindcss/postcss](https://tailwindcss.com) ([source](https://github.com/tailwindlabs/tailwindcss/tree/HEAD/packages/@tailwindcss-postcss)) | [`4.0.17` -> `4.1.3`](https://renovatebot.com/diffs/npm/@tailwindcss%2fpostcss/4.0.17/4.1.3) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [tailwindcss](https://tailwindcss.com) ([source](https://github.com/tailwindlabs/tailwindcss/tree/HEAD/packages/tailwindcss)) | [`4.0.17` -> `4.1.3`](https://renovatebot.com/diffs/npm/tailwindcss/4.0.17/4.1.3) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>tailwindlabs/tailwindcss (@​tailwindcss/postcss)</summary> ### [`v4.1.3`](https://github.com/tailwindlabs/tailwindcss/blob/HEAD/CHANGELOG.md#413---2025-04-04) [Compare Source](tailwindlabs/tailwindcss@v4.1.2...v4.1.3) ##### Fixed - Show warning when using unsupported bare value data type in `--value(…)` ([#​17464](tailwindlabs/tailwindcss#17464)) - PostCSS: Ensure changes to the input CSS file don't generate stale output when using Turbopack ([#​17554](tailwindlabs/tailwindcss#17554)) - Ensure classes are detected in Ruby's `%w` syntax in Slim templates ([#​17557](tailwindlabs/tailwindcss#17557)) ### [`v4.1.2`](https://github.com/tailwindlabs/tailwindcss/blob/HEAD/CHANGELOG.md#412---2025-04-03) [Compare Source](tailwindlabs/tailwindcss@v4.1.1...v4.1.2) ##### Fixed - Don't rely on the presence of `@layer base` to polyfill `@property` ([#​17506](tailwindlabs/tailwindcss#17506)) - Support setting multiple inset shadows as arbi...
Closes #17508
This PR fixes another issue we found that caused dev builds with Next.js and Turbopack to resolve the CSS file that was saved one revision before the latest update.
When debugging this we noticed that the PostCSS entry is called twice for every one update when changing the input CSS file directly. That was caused by the input file itself being added as a dependency so you would first get the callback that a dependency has updated (at which point we look at the file system and figure out we need a full-rebuild because the input.css file has changed) and then another callback for when the input file has updated. The problem with the second callback was that the file-system was already scanned for updates and since this includes the
mtimesfor the input file, we seemingly thought that the input file did not change. However, the issue is that the first callback actually came with an outdated PostCSS input AST...We found that this problem arises when you register the input CSS as a dependency of itself. This is not expected and we actually guard against this in the PostCSS client. However, we found that the input
fromargument is a relative path when using Next.js with Turbopack so that check was not working as expected.Test plan
Added the change to the repro from #17508 and it seems to work fine now.
Screen.Recording.2025-04-04.at.12.48.19.mov
Also added a unit test to ensure we document that the input file path can be a relative path.