Skip to content

fix: link the stylesheets of a lazily loaded template with no client code - #316

Merged
DylanPiercey merged 1 commit into
mainfrom
dpiercey-ws-persisted-pages-backport-cpt6dc
Sep 18, 2026
Merged

DylanPiercey merged 1 commit into
mainfrom
dpiercey-ws-persisted-pages-backport-cpt6dc

Conversation

@DylanPiercey

Copy link
Copy Markdown
Contributor

A lazily loaded template's stylesheets are collected from the client bundle graph to flush with its html, but that ran after vite's css plugin: a template whose client chunk is pure css is pruned there, its css folded into static importers only, and the load entry reaches it through a dynamic import that keeps just the pruned chunk's name. So a lazy template with a <style> and no client code lost its stylesheet link and painted unstyled until its module script ran. The pre plugin now collects each load entry's css before that pass. Adds a fixture for the scriptless case.

🤖 Generated with Claude Code

…code

A load entry's css is collected in the post plugin's generateBundle by
walking the entry chunk's imports, but vite's css plugin has run by
then: a template whose client chunk is pure css is pruned, its css
folded into static importers only, and the load entry reaches it
through a dynamic import that keeps just the pruned chunk's name. The
pre plugin now collects each load entry's css before that pass, so the
stylesheet flushes with the html it styles instead of arriving once the
module script runs, with the html painted unstyled until then.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fafb47f

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

This PR includes changesets to release 1 package
Name Type
@marko/vite Patch

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

@DylanPiercey
DylanPiercey merged commit 6795020 into main Sep 18, 2026
7 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 18, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Roadmap Oct 2, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in Roadmap Oct 2, 2026
@DylanPiercey DylanPiercey self-assigned this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant