fix: CSS modules not working in _app/_layout/_error and across routes in non-island components (#3781)

This commit is contained in:
Hajime-san
2026-05-27 08:32:41 +02:00
committed by GitHub
parent 072d09297e
commit 3afaaf4f78
30 changed files with 464 additions and 39 deletions
@@ -0,0 +1,10 @@
// @ts-ignore upstream issue https://github.com/denoland/deno/issues/30560
import styles from "./CssModulesNonIsland.module.css";
export function CssModulesNonIsland() {
return (
<div class="green">
<h1 class={styles.root}>green text</h1>
</div>
);
}
@@ -0,0 +1,9 @@
import styles from "./CssModulesNonIsland2.module.css";
export function CssModulesNonIsland2() {
return (
<div class="blue">
<h1 class={styles.root}>blue text</h1>
</div>
);
}
@@ -0,0 +1,9 @@
import styles from "./CssModulesNonIsland3.module.css";
export function CssModulesNonIsland3() {
return (
<div class="red">
<h1 class={styles.root}>red text</h1>
</div>
);
}
@@ -0,0 +1,9 @@
import styles from "./CssModulesNonIsland4.module.css";
export function CssModulesNonIsland4() {
return (
<div class="orange">
<h1 class={styles.root}>orange text</h1>
</div>
);
}
@@ -0,0 +1,3 @@
.root {
color: green;
}
@@ -0,0 +1,3 @@
.root {
color: blue;
}
@@ -0,0 +1,3 @@
.root {
color: red;
}
@@ -0,0 +1,3 @@
.root {
color: orange;
}
@@ -0,0 +1,5 @@
import { App, staticFiles } from "@fresh/core";
export const app = new App()
.use(staticFiles())
.fsRoutes();
@@ -0,0 +1,6 @@
import { CssModulesNonIsland4 } from "../components/CssModuleNonIsland4.tsx";
import { define } from "../utils.ts";
export default define.page(() => {
return <CssModulesNonIsland4 />;
});
@@ -0,0 +1,17 @@
import type { PageProps } from "fresh";
import { CssModulesNonIsland } from "../components/CssModuleNonIsland.tsx";
export default function App({ Component }: PageProps) {
return (
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<CssModulesNonIsland />
<Component />
</body>
</html>
);
}
@@ -0,0 +1,6 @@
import { define } from "../utils.ts";
import { CssModulesNonIsland2 } from "../components/CssModuleNonIsland2.tsx";
export default define.page(() => {
return <CssModulesNonIsland2 />;
});
@@ -0,0 +1,11 @@
import { CssModulesNonIsland3 } from "../components/CssModuleNonIsland3.tsx";
import { define } from "../utils.ts";
export default define.layout(({ Component }) => {
return (
<>
<CssModulesNonIsland3 />
<Component />
</>
);
});
@@ -0,0 +1,5 @@
import { define } from "../utils.ts";
export default define.page(() => {
throw new Error("boom");
});
@@ -0,0 +1,3 @@
export default function Hello() {
return <h1>ok</h1>;
}
@@ -0,0 +1,4 @@
import { createDefine } from "@fresh/core";
// deno-lint-ignore no-explicit-any
export const define = createDefine<any>();
@@ -0,0 +1,6 @@
import { defineConfig } from "vite";
import { fresh } from "@fresh/plugin-vite";
export default defineConfig({
plugins: [fresh()],
});