tailwindcss/packages
Lazizbek Ergashev 50daebded0
Prevent @tailwindcss/vite crash under Vite's experimental bundledDev (#20379)
## Summary

Under Vite's experimental `bundledDev` mode, the `hotUpdate` hook in
`@tailwindcss/vite` gets called without a `server`. Vite only passes `{
type, file, modules }` here, but the hook loops over
`Object.values(server.environments)`, so editing any file (JS, CSS, or
HTML) throws `TypeError: Cannot read properties of undefined (reading
'environments')` and the dev server build fails.

The fix returns early when `server` is missing. Those environment loops
only look at environments other than the current one, and the
server-level `hot`/`ws` reload channels don't exist in this mode, so
bailing out leaves the classic (non-`bundledDev`) dev path untouched.

Fixes #20378

## Test plan

- Added a unit test that calls `hotUpdate` without a `server` and checks
it doesn't throw. It fails on the current code and passes with the
guard.
- Reproduced with a Vite 8 project using `experimental.bundledDev:
true`: before the change, editing any JS/CSS/HTML file crashed the dev
server; after it, edits work.
- `pnpm run test` and the `@tailwindcss/vite` integration suite both
pass.


[ci-all]

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2026-08-03 15:10:06 +02:00
..
@tailwindcss-browser 4.3.3 (#20334) 2026-07-16 07:21:50 -04:00
@tailwindcss-cli 4.3.3 (#20334) 2026-07-16 07:21:50 -04:00
@tailwindcss-node 4.3.3 (#20334) 2026-07-16 07:21:50 -04:00
@tailwindcss-postcss 4.3.3 (#20334) 2026-07-16 07:21:50 -04:00
@tailwindcss-standalone 4.3.3 (#20334) 2026-07-16 07:21:50 -04:00
@tailwindcss-turbopack Add Turbopack loader integration coverage 2026-07-31 15:13:38 +02:00
@tailwindcss-upgrade try converting variants with arbitrary values to builtin variants 2026-08-03 13:11:43 +02:00
@tailwindcss-vite Prevent @tailwindcss/vite crash under Vite's experimental bundledDev (#20379) 2026-08-03 15:10:06 +02:00
@tailwindcss-webpack 4.3.3 (#20334) 2026-07-16 07:21:50 -04:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss try converting variants with arbitrary values to builtin variants 2026-08-03 13:11:43 +02:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00