Skip to content

fix: normalize island CSS paths for Windows compatibility - #69

Merged
Brooooooklyn merged 1 commit into
mainfrom
04-02-fix_normalize_island_css_paths_for_windows_compatibility
Apr 2, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
04-02-fix_normalize_island_css_paths_for_windows_compatibility

Conversation

@shulaoda

@shulaoda shulaoda commented Apr 2, 2026

Copy link
Copy Markdown
Member

Summary

Fix island CSS serving broken on Windows during dev. Layout <style> blocks in island pages (including .md pages) returned 404 because of path separator mismatches (\ vs /).

Problem

On Windows, path.resolve() produces backslash paths (e.g. E:\foo\pages\layout.vue), but Vite internally normalizes all module IDs to forward slashes. This caused two failures in the island CSS pipeline:

  1. islandCssFiles stored backslash paths — populated via resolve(pagesDir, layout.filePath) which returns \-separated paths on Windows.
  2. load hook received forward-slash IDs — when resolveId returned a backslash path like E:\foo\layout.vue.css, Vite normalized it to E:/foo/layout.vue.css before passing to load. The islandCssFiles.has() check then failed, causing transformRequest to throw ERR_LOAD_URL, which was silently caught, resulting in a 404.

The same mismatch affected the dev server middleware (configureIslandCssServer) and the file watcher callback.

Fix

Apply normalizePath() (from Vite) consistently to ensure all paths stored in islandCssFiles and all paths used for lookups use forward slashes:

  • packages/void/src/pages/islands-plugin.ts — normalize paths in configureIslandCssServer (middleware resolve + watcher callback)
  • packages/vue/src/plugin-islands.ts — normalize when populating islandCssFiles and in resolveId hook
  • packages/react/src/plugin-islands.ts — same changes as vue
  • packages/solid/src/plugin-islands.ts — same changes as vue
  • packages/svelte/src/plugin-islands.ts — same changes as vue

@shulaoda
shulaoda force-pushed the 04-02-fix_normalize_island_css_paths_for_windows_compatibility branch from cdd0599 to ce30d03 Compare April 2, 2026 14:55
@shulaoda
shulaoda force-pushed the 04-02-fix_normalize_island_css_paths_for_windows_compatibility branch from ce30d03 to c3d573c Compare April 2, 2026 14:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Windows dev-server 404s for island/layout CSS by ensuring Vite module IDs and internal lookup keys use consistent forward-slash paths.

Changes:

  • Normalize stored island/layout file paths via normalizePath() when populating islandCssFiles (Vue/React/Solid/Svelte).
  • Normalize .css virtual module resolution inputs in resolveId to ensure islandCssFiles.has() lookups work on Windows.
  • Normalize paths used by the dev server middleware + file watcher invalidation in configureIslandCssServer (void core).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/vue/src/plugin-islands.ts Normalizes island/layout CSS file paths and resolveId lookup keys for Windows-safe matching.
packages/react/src/plugin-islands.ts Same normalization strategy as Vue for island/layout CSS resolution.
packages/solid/src/plugin-islands.ts Same normalization strategy as Vue for island/layout CSS resolution.
packages/svelte/src/plugin-islands.ts Same normalization strategy as Vue for island/layout CSS resolution.
packages/void/src/pages/islands-plugin.ts Normalizes watcher and middleware paths before islandCssFiles lookups and module invalidation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/void/src/pages/islands-plugin.ts
@Brooooooklyn
Brooooooklyn merged commit 63036fa into main Apr 2, 2026
11 of 12 checks passed
@Brooooooklyn
Brooooooklyn deleted the 04-02-fix_normalize_island_css_paths_for_windows_compatibility branch April 2, 2026 15:06
cpojer pushed a commit that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants