Files
Ossaid c93b4a02fd Inject styles from dynamically imported components on first dev server load (#15988)
* fix(css): inject styles from dynamically imported components on first dev load

In Astro 6, `collectCSSWithOrder()` walks the Vite module graph to find CSS
dependencies, but dynamically imported modules are registered in the graph
without being transformed yet — their `importedModules` set is empty, so the
CSS walk terminates prematurely and their styles are never injected.

Add `ensureModulesLoaded()` which recursively walks the graph and eagerly
fetches any untransformed modules via `env.fetchModule()` before the CSS
collection walk runs. This populates each module's `importedModules` set,
making CSS dependencies from dynamically imported components visible on the
first page load.

Fixes #15983

* chore: update lockfile for css-dynamic-import-dev fixture

* fix(css): skip propagated asset modules in ensureModulesLoaded

---------

Co-authored-by: Matthew Phillips <matthewphillips@cloudflare.com>
2026-03-19 10:02:19 -04:00

50 lines
1.1 KiB
Plaintext

node_modules/
/triage/
/.compiler/
dist/
temp/
*.tsbuildinfo
.DS_Store
.vercel
.netlify
_site/
.astro/
scripts/smoke/*-main/
scripts/memory/project/src/pages/
benchmark/projects/
benchmark/results/
test-results/
*.log
package-lock.json
.turbo/
.eslintcache
.pnpm-store
.vscode-test/
.claude
# do not commit .env files or any files that end with `.env`
*.env
packages/astro/src/**/*.prebuilt.ts
packages/astro/src/**/*.prebuilt-dev.ts
packages/astro/test/units/_temp-fixtures/*
!packages/astro/test/units/_temp-fixtures/package.json
packages/integrations/**/.netlify/
# exclude IntelliJ/WebStorm stuff
.idea
# ignore content collection generated files
packages/**/test/**/fixtures/**/.astro/
packages/**/test/**/fixtures/**/env.d.ts
packages/**/e2e/**/fixtures/**/.astro/
packages/**/e2e/**/fixtures/**/env.d.ts
examples/**/.astro/
examples/**/env.d.ts
# make it easy for people to add project-specific Astro settings that they don't
# want to share with others (see
# https://github.com/withastro/astro/pull/11759#discussion_r1721444711)
*.code-workspace
packages/astro/e2e/fixtures/cloudflare/.wrangler/deploy/config.json