fix: CSS modules not working in _app/_layout/_error and across routes in dev#3764
Merged
bartlomieju merged 3 commits intomainfrom Apr 9, 2026
Merged
fix: CSS modules not working in _app/_layout/_error and across routes in dev#3764bartlomieju merged 3 commits intomainfrom
bartlomieju merged 3 commits intomainfrom
Conversation
#3633) Fixes two CSS modules issues: 1. Islands in _app.tsx, _layout.tsx, or _error.tsx had their CSS missing because they were discovered after <head> was already rendered. Now FreshScripts (at end of <body>) emits <link> tags for any island CSS that wasn't already injected in <head>. 2. In dev mode, CSS modules for islands shared across multiple routes only worked on the first page visited. The dev server's CSS collection now also walks island module graphs in addition to the client entry, ensuring all island CSS is collected regardless of which route is accessed first. Closes #3633 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds an AppNav island with a CSS module to _app.tsx and a second page that shares the CssModules island. Tests verify: 1. CSS modules from islands in _app.tsx are injected into the page (both build and dev mode) 2. CSS modules from shared islands work on the second page visited, not just the first (both build and dev mode) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@bartlomieju |
This was referenced Apr 27, 2026
Merged
bartlomieju
added a commit
that referenced
this pull request
Apr 27, 2026
- Bump `@fresh/core` to `2.3.1` - Bump `@fresh/init` to `2.3.1` - Bump `@fresh/update` to `2.3.1` - Bump `@fresh/plugin-vite` from `1.0.8` to `1.1.0` - Bump `@fresh/plugin-tailwind-v3` from `1.0.1` to `1.1.0` The plugin packages were not published during the 2.3.0 release despite having significant changes merged. Notable fixes in `@fresh/plugin-vite` include immutable caching for Vite-built assets (#3761), CSS modules in layouts (#3764), and multiple `staticDir` support (#3759). Also updates `FRESH_VITE_PLUGIN` version constant in `@fresh/init` so new projects scaffold with the correct plugin version. Closes #3784
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Islands used in
_app.tsx,_layout.tsx, or_error.tsxare discovered after<head>has already rendered, so their CSS<link>tags were never injected.FreshScripts(at end of<body>) now emits late CSS for any islands missed byRemainingHead, using aninjectedCssset to avoid duplicates.In dev mode,
collectCssonly walked thefresh:client-entrymodule graph, missing CSS imported by island modules. The dev server now also walksfresh-island::*module graphs when collecting CSS.Note: late-injected
<link>tags in<body>may cause a brief flash of unstyled content — this is inherent to the problem since<head>renders before<body>islands are discovered.Closes #3633
Test plan
css modules in _app.tsx island are injected(build + dev)css modules work on second page with shared island(build + dev)🤖 Generated with Claude Code