Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nuxt integration #14319

Merged
merged 4 commits into from
Sep 4, 2024
Merged

Fix Nuxt integration #14319

merged 4 commits into from
Sep 4, 2024

Conversation

philipp-spiess
Copy link
Member

@philipp-spiess philipp-spiess commented Sep 3, 2024

We noticed that Nuxt projects were not working with the tailwindcss project. The issue was traced down to the fact that Nuxt starts multiple Vite dev servers and calling the experimental waitForRequestsIdle() on one of the test servers would never resolve.

This was fixed upstream and is part of the latest Vite/Nuxt release: vitejs/vite#17980.

We still need to handle the fact that Vite can spawn multiple dev servers. This is necessary because when we invalidate all roots, we need to find that module inside all of the spawned servers. If we only look at the last server (what we have done before), we would not find the module and thus could not invalidate it.

@philipp-spiess philipp-spiess changed the title Add Nuxt integration test Fix Nuxt integration Sep 4, 2024
@philipp-spiess philipp-spiess marked this pull request as ready for review September 4, 2024 11:51
@@ -169,7 +168,7 @@ export default function tailwindcss(): Plugin[] {
},
transform(src, id, options) {
let extension = getExtension(id)
if (extension === '' || extension === 'css') return
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an optimization that makes sure vite <style> blocks aren't scanned for candidates in addition to css files.

@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Ensure content globs defined in `@config` files are relative to that file ([#14314](https://github.com/tailwindlabs/tailwindcss/pull/14314))
- Ensure CSS `theme()` functions are evaluated in media query ranges with collapsed whitespace ((#14321)[https://github.com/tailwindlabs/tailwindcss/pull/14321])
- Fix support for Nuxt projects in the Vite plugin (requires Nuxt 3.13.1+) ([#14319](https://github.com/tailwindlabs/tailwindcss/pull/14319))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not happy about this line but if we want to mention the improved Nuxt support we should mention the version number, otherwise people try it and it won't work 😢

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me tbh

@@ -193,7 +192,7 @@ export default function tailwindcss(): Plugin[] {
// The reason why we can not rely on the invalidation here is that the
// users would otherwise see a flicker in the styles as the CSS might
// be loaded with an invalid set of candidates first.
await server?.waitForRequestsIdle?.(id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to bump the minimum Vite version to the one where waitForRequestsIdle was introduced if it's not already btw.

@adamwathan adamwathan merged commit 719a535 into next Sep 4, 2024
3 checks passed
@adamwathan adamwathan deleted the test/nuxt branch September 4, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants