Skip to content

Commit c4b7d02

Browse files
PostCSS: Fix Turbopack 'one-revision-behind' bug
1 parent fc94ab4 commit c4b7d02

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- PostCSS: Resolve an issue where changes to the input CSS file showed outdated content when using Turbopack
1113

1214
## [4.1.2] - 2025-04-03
1315

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* the content for this file is set in the tests */

packages/@tailwindcss-postcss/src/index.test.ts

+22
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,25 @@ describe('concurrent builds', () => {
420420
expect(await promise2).toContain('.red')
421421
})
422422
})
423+
424+
test('does not register the input file as a dependency, even if it is passed in as relative path', async () => {
425+
let processor = postcss([
426+
tailwindcss({ base: `${__dirname}/fixtures/example-project`, optimize: { minify: false } }),
427+
])
428+
429+
let result = await processor.process(`@tailwind utilities`, { from: './input.css' })
430+
431+
expect(result.css.trim()).toMatchInlineSnapshot(`
432+
".underline {
433+
text-decoration-line: underline;
434+
}"
435+
`)
436+
437+
// Check for dependency messages
438+
expect(result.messages).not.toContainEqual({
439+
type: 'dependency',
440+
file: expect.stringMatching(/input.css$/g),
441+
parent: expect.any(String),
442+
plugin: expect.any(String),
443+
})
444+
})

packages/@tailwindcss-postcss/src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,12 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
223223
if (compiler.features & Features.Utilities) {
224224
DEBUG && I.start('Register dependency messages')
225225
// Add all found files as direct dependencies
226+
// Note: With Turbopack, the input file might not be a resolved path
227+
let resolvedInputFile = path.resolve(base, inputFile)
226228
for (let file of context.scanner.files) {
227229
let absolutePath = path.resolve(file)
228230
// The CSS file cannot be a dependency of itself
229-
if (absolutePath === result.opts.from) {
231+
if (absolutePath === resolvedInputFile) {
230232
continue
231233
}
232234
result.messages.push({

0 commit comments

Comments
 (0)