-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix CSS collection in dev mode with content collections #15167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 047e56f 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 |
|
| 📦 Package | 🔒 Before | 🔓 After |
|---|---|---|
| @cloudflare/kv-asset-handler | trusted-with-provenance | none |
| @cloudflare/unenv-preset | trusted-with-provenance | none |
| workerd | trusted-with-provenance | none |
| undici | provenance | none |
| miniflare | trusted-with-provenance | none |
| youch | provenance | none |
| @cloudflare/workerd-darwin-64 | trusted-with-provenance | none |
| @cloudflare/workerd-darwin-arm64 | trusted-with-provenance | none |
| @cloudflare/workerd-linux-64 | trusted-with-provenance | none |
| @cloudflare/workerd-linux-arm64 | trusted-with-provenance | none |
| @cloudflare/workerd-windows-64 | trusted-with-provenance | none |
| wrangler | trusted-with-provenance | none |
| ): Generator<ImportedDevStyle & { id: string; idKey: string }, void, unknown> { | ||
| seen.add(id); | ||
|
|
||
| // Stop traversing if we reach a propagation stopping point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a more valuable comment is describing why we need to stop the propagation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point. I just pushed an updated comment trying to clarify that, altho I'm definitely not the most well-versed in assets propagation so I hope it makes sense and helps enough. Let me know if you think it can be improved further.
Changes
Initially reported on Discord, this PR fixes an issue in development mode, when using content collections, where CSS from a previously visited page would incorrectly apply to other pages not using the components with that CSS.
astro:contentneeds to be imported in different pages to trigger the issue.vite-plugin-css, I think we need to stop traversing when collecting CSS when a propagation stopping point is reached, like we do in thevite-plugin-astro-serverwhen recursively crawling the module graph to get all style files.Testing
I updated a fixture to reproduce the issue and added a test to verify the fix by visting two different pages. Before the changes, the second page would incorrectly include CSS from a componment used only in the first page. After the changes, the second page correctly does not include that CSS.
Docs
This is a bug fix; no doc updates are needed.