Skip to content

Commit d9c5e95

Browse files
committed
fix(rsc): avoid unnecessary server hmr due to tailwind module deps
1 parent c602225 commit d9c5e95

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('unused file text-[#f12345]')

packages/plugin-rsc/src/plugin.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,16 @@ export default function vitePluginRsc(
398398

399399
if (!isInsideClientBoundary(ctx.modules)) {
400400
if (this.environment.name === 'rsc') {
401+
// detect if this module is only created as css deps (e.g. tailwind)
402+
// (NOTE: this is not necessary since Vite 7.1.0-beta.0 https://github.com/vitejs/vite/pull/20391 )
403+
if (
404+
ctx.modules
405+
.flatMap((m) => [...m.importers])
406+
.every((m) => m.id && isCSSRequest(m.id))
407+
) {
408+
return
409+
}
410+
401411
// transform js to surface syntax errors
402412
for (const mod of ctx.modules) {
403413
if (mod.type === 'js') {
@@ -426,6 +436,7 @@ export default function vitePluginRsc(
426436
// Server files can be included in client module graph, for example,
427437
// when `addWatchFile` is used to track js files as style dependency (e.g. tailwind)
428438
// In this case, reload all importers (for css hmr), and return empty modules to avoid full-reload.
439+
// (NOTE: this is not necessary since Vite 7.1.0-beta.0 https://github.com/vitejs/vite/pull/20391 )
429440
const env = ctx.server.environments.rsc!
430441
const mod = env.moduleGraph.getModuleById(ctx.file)
431442
if (mod) {

0 commit comments

Comments
 (0)