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

Enable Vite's waitForRequestsIdle() for client requests only #13394

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet!
### Fixed

- Enable Vite's `waitForRequestsIdle()` for client requests only ([#13394](https://github.com/tailwindlabs/tailwindcss/pull/13394))

## [4.0.0-alpha.11] - 2024-03-27

Expand Down
15 changes: 7 additions & 8 deletions packages/@tailwindcss-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,18 @@ export default function tailwindcss(): Plugin[] {
name: '@tailwindcss/vite:generate:serve',
apply: 'serve',

async transform(src, id) {
async transform(src, id, options) {
if (!isTailwindCssFile(id, src)) return

// In serve mode, we treat cssModules as a set, ignoring the value.
cssModules[id] = ''

// TODO: Re-enable waitForRequestsIdle once issues with it hanging are
// fixed. Until then, this transformation may run multiple times in
// serve mode, possibly giving a FOUC.
//
// Wait until all other files have been processed, so we can extract all
// candidates before generating CSS.
// await server?.waitForRequestsIdle?.(id)
if (!options?.ssr) {
// Wait until all other files have been processed, so we can extract
// all candidates before generating CSS. This must not be called
// during SSR or it will block the server.
await server?.waitForRequestsIdle?.(id)
}

let code = await transformWithPlugins(this, id, generateCss(src))
return { code }
Expand Down
Loading