diff --git a/CHANGELOG.md b/CHANGELOG.md index a4b615ca0..a96a1d89e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Show warning when using unsupported bare value data type in `--value(…)` ([#17464](https://github.com/tailwindlabs/tailwindcss/pull/17464)) +- PostCSS: Resolve an issue where changes to the input CSS file showed outdated content when using Turbopack ([#17554](https://github.com/tailwindlabs/tailwindcss/pull/17554)) ## [4.1.2] - 2025-04-03 diff --git a/packages/@tailwindcss-postcss/src/fixtures/example-project/input.css b/packages/@tailwindcss-postcss/src/fixtures/example-project/input.css new file mode 100644 index 000000000..f1af498fc --- /dev/null +++ b/packages/@tailwindcss-postcss/src/fixtures/example-project/input.css @@ -0,0 +1 @@ +/* the content for this file is set in the tests */ diff --git a/packages/@tailwindcss-postcss/src/index.test.ts b/packages/@tailwindcss-postcss/src/index.test.ts index 5827d819d..4227d6fbb 100644 --- a/packages/@tailwindcss-postcss/src/index.test.ts +++ b/packages/@tailwindcss-postcss/src/index.test.ts @@ -420,3 +420,25 @@ describe('concurrent builds', () => { expect(await promise2).toContain('.red') }) }) + +test('does not register the input file as a dependency, even if it is passed in as relative path', async () => { + let processor = postcss([ + tailwindcss({ base: `${__dirname}/fixtures/example-project`, optimize: { minify: false } }), + ]) + + let result = await processor.process(`@tailwind utilities`, { from: './input.css' }) + + expect(result.css.trim()).toMatchInlineSnapshot(` + ".underline { + text-decoration-line: underline; + }" + `) + + // Check for dependency messages + expect(result.messages).not.toContainEqual({ + type: 'dependency', + file: expect.stringMatching(/input.css$/g), + parent: expect.any(String), + plugin: expect.any(String), + }) +}) diff --git a/packages/@tailwindcss-postcss/src/index.ts b/packages/@tailwindcss-postcss/src/index.ts index e728c2f95..bac5c5b9a 100644 --- a/packages/@tailwindcss-postcss/src/index.ts +++ b/packages/@tailwindcss-postcss/src/index.ts @@ -223,10 +223,12 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin { if (compiler.features & Features.Utilities) { DEBUG && I.start('Register dependency messages') // Add all found files as direct dependencies + // Note: With Turbopack, the input file might not be a resolved path + let resolvedInputFile = path.resolve(base, inputFile) for (let file of context.scanner.files) { let absolutePath = path.resolve(file) // The CSS file cannot be a dependency of itself - if (absolutePath === result.opts.from) { + if (absolutePath === resolvedInputFile) { continue } result.messages.push({