Skip to content

fix(astro): handle case-insensitive paths when matching style modules#16237

Open
slegarraga wants to merge 1 commit intowithastro:mainfrom
slegarraga:fix/issue-14013
Open

fix(astro): handle case-insensitive paths when matching style modules#16237
slegarraga wants to merge 1 commit intowithastro:mainfrom
slegarraga:fix/issue-14013

Conversation

@slegarraga
Copy link
Copy Markdown

On case-insensitive filesystems (Windows, macOS), running npm run dev from a path with different casing than the canonical filesystem path caused inline <style> blocks to be silently dropped.

Root cause

The HMR handler in vite-plugin-astro/hmr.ts compared file paths using strict equality. When the casing of ctx.file (provided by Vite's watcher using the actual filesystem casing) differed from the key stored in the compile metadata map, lookups failed and CSS was never returned.

Changes

  • Normalize path casing for comparison when looking up compile metadata on win32 and darwin.
  • Normalize CSS dependency paths using the same approach when checking if an updated file is a CSS dependency.
  • Add a changeset for the astro package.

Testing

Existing HMR tests continue to pass. The fix is scoped to case-insensitive platforms so Linux behavior is unaffected.

Fixes #14013

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 6, 2026

🦋 Changeset detected

Latest commit: c544c5f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Apr 6, 2026
On case-insensitive filesystems (Windows, macOS), running dev from a path whose casing differs from the canonical filesystem path (e.g. d:\dev\astro-demo vs D:\dev\astro-demo) caused inline <style> blocks to be silently dropped. The HMR handler compared file paths using strict equality, which failed when the casing of ctx.file differed from the key stored in the compile metadata map.

Normalize path casing for comparison on case-insensitive platforms only (win32 and darwin), leaving Linux behavior completely unchanged.

Fixes withastro#14013
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 6, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing slegarraga:fix/issue-14013 (771c183) with main (5557dca)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (2c9bf5e) during the generation of this report, so 5557dca was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Style missing when path case differs

1 participant