PostCSS: Fix Turbopack 'one-revision-behind' bug #17554
Merged
+27
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
mtimes
for 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
from
argument 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.