Skip to content
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
8 changes: 4 additions & 4 deletions packages/react/src/plugin-islands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
for (const page of pageScan.pages) {
if (!page.island) continue;
if (/\.(tsx|jsx)$/.test(page.componentPath)) {
islandCssFiles.add(resolve(pagesDir, page.componentPath));
islandCssFiles.add(normalizePath(resolve(pagesDir, page.componentPath)));
}
const layoutChain = resolveEffectiveLayoutChain(
page,
pageScan.layouts,
pageScan.namedLayouts,
);
for (const layout of layoutChain) {
islandCssFiles.add(resolve(pagesDir, layout.filePath));
islandCssFiles.add(normalizePath(resolve(pagesDir, layout.filePath)));
}
}

Expand All @@ -116,10 +116,10 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
// Virtual island CSS modules — no \0 prefix so Vite CSS pipeline processes them.
// Return absolute path so CSS @import resolution uses the correct directory.
if (source.endsWith(".css")) {
const srcPath = source.slice(0, -4);
const srcPath = normalizePath(source.slice(0, -4));
if (islandCssFiles.has(srcPath)) return srcPath + ".css";
if (srcPath.startsWith("/")) {
const absPath = resolve(viteRoot, srcPath.slice(1));
const absPath = normalizePath(resolve(viteRoot, srcPath.slice(1)));
if (islandCssFiles.has(absPath)) return absPath + ".css";
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/solid/src/plugin-islands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
for (const page of pageScan.pages) {
if (!page.island) continue;
if (/\.(tsx|jsx)$/.test(page.componentPath)) {
islandCssFiles.add(resolve(pagesDir, page.componentPath));
islandCssFiles.add(normalizePath(resolve(pagesDir, page.componentPath)));
}
const layoutChain = resolveEffectiveLayoutChain(
page,
pageScan.layouts,
pageScan.namedLayouts,
);
for (const layout of layoutChain) {
islandCssFiles.add(resolve(pagesDir, layout.filePath));
islandCssFiles.add(normalizePath(resolve(pagesDir, layout.filePath)));
}
}

Expand All @@ -142,10 +142,10 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
// Virtual island CSS modules — no \0 prefix so Vite CSS pipeline processes them.
// Return absolute path so CSS @import resolution uses the correct directory.
if (source.endsWith(".css")) {
const srcPath = source.slice(0, -4);
const srcPath = normalizePath(source.slice(0, -4));
if (islandCssFiles.has(srcPath)) return srcPath + ".css";
if (srcPath.startsWith("/")) {
const absPath = resolve(viteRoot, srcPath.slice(1));
const absPath = normalizePath(resolve(viteRoot, srcPath.slice(1)));
if (islandCssFiles.has(absPath)) return absPath + ".css";
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/svelte/src/plugin-islands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
for (const page of pageScan.pages) {
if (!page.island) continue;
if (page.componentPath.endsWith(".svelte")) {
islandCssFiles.add(resolve(pagesDir, page.componentPath));
islandCssFiles.add(normalizePath(resolve(pagesDir, page.componentPath)));
}
const layoutChain = resolveEffectiveLayoutChain(
page,
pageScan.layouts,
pageScan.namedLayouts,
);
for (const layout of layoutChain) {
islandCssFiles.add(resolve(pagesDir, layout.filePath));
islandCssFiles.add(normalizePath(resolve(pagesDir, layout.filePath)));
}
}

Expand All @@ -132,10 +132,10 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
// Virtual island CSS modules — no \0 prefix so Vite CSS pipeline processes them.
// Return absolute path so CSS @import resolution uses the correct directory.
if (source.endsWith(".css")) {
const srcPath = source.slice(0, -4);
const srcPath = normalizePath(source.slice(0, -4));
if (islandCssFiles.has(srcPath)) return srcPath + ".css";
if (srcPath.startsWith("/")) {
const absPath = resolve(viteRoot, srcPath.slice(1));
const absPath = normalizePath(resolve(viteRoot, srcPath.slice(1)));
if (islandCssFiles.has(absPath)) return absPath + ".css";
}
}
Expand Down
9 changes: 5 additions & 4 deletions packages/void/src/pages/islands-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ViteDevServer } from "vite";
import { normalizePath, type ViteDevServer } from "vite";
import { existsSync, readFileSync, readdirSync } from "node:fs";
import { resolve } from "node:path";
import { resolveEffectiveLayoutChain } from "./scan";
Expand Down Expand Up @@ -175,21 +175,22 @@ export function configureIslandCssServer(
rebuildCssMap: () => void,
): void {
server.watcher.on("change", (path) => {
if (!islandCssFiles.has(path)) return;
const normalizedPath = normalizePath(path);
if (!islandCssFiles.has(normalizedPath)) return;
rebuildCssMap();
Comment thread
shulaoda marked this conversation as resolved.
for (const env of Object.values(server.environments)) {
const mod = env.moduleGraph.getModuleById("\0" + ISLANDS_RENDERER_ID);
if (mod) env.moduleGraph.invalidateModule(mod);
}
const cssMod = server.environments.client?.moduleGraph.getModuleById(path + ".css");
const cssMod = server.environments.client?.moduleGraph.getModuleById(normalizedPath + ".css");
if (cssMod) server.environments.client.moduleGraph.invalidateModule(cssMod);
});

server.middlewares.use(async (req, res, next) => {
if (!req.url) return next();
const url = req.url.split("?")[0];
if (!url.endsWith(".css")) return next();
const srcPath = resolve(viteRoot, url.slice(1, -4));
const srcPath = normalizePath(resolve(viteRoot, url.slice(1, -4)));
if (!islandCssFiles.has(srcPath)) return next();
try {
const result = await server.environments.client.transformRequest(url);
Expand Down
8 changes: 4 additions & 4 deletions packages/vue/src/plugin-islands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
for (const page of pageScan.pages) {
if (!page.island) continue;
if (page.componentPath.endsWith(".vue")) {
islandCssFiles.add(resolve(pagesDir, page.componentPath));
islandCssFiles.add(normalizePath(resolve(pagesDir, page.componentPath)));
}
const layoutChain = resolveEffectiveLayoutChain(
page,
pageScan.layouts,
pageScan.namedLayouts,
);
for (const layout of layoutChain) {
islandCssFiles.add(resolve(pagesDir, layout.filePath));
islandCssFiles.add(normalizePath(resolve(pagesDir, layout.filePath)));
}
}

Expand All @@ -154,10 +154,10 @@ export function islandsPlugin(pagesDir: string): Plugin[] {
// Virtual island CSS modules — no \0 prefix so Vite CSS pipeline processes them.
// Return absolute path so CSS @import resolution uses the correct directory.
if (source.endsWith(".css")) {
const srcPath = source.slice(0, -4);
const srcPath = normalizePath(source.slice(0, -4));
if (islandCssFiles.has(srcPath)) return srcPath + ".css";
if (srcPath.startsWith("/")) {
const absPath = resolve(viteRoot, srcPath.slice(1));
const absPath = normalizePath(resolve(viteRoot, srcPath.slice(1)));
if (islandCssFiles.has(absPath)) return absPath + ".css";
}
}
Expand Down
Loading