Skip to content

Replace internal cssScopeTo implementation to vite.cssScopeTo - #13347

Merged
ematipico merged 8 commits into
mainfrom
vite-css-scope-to
Mar 6, 2025
Merged

ematipico merged 8 commits into
mainfrom
vite-css-scope-to

Conversation

@bluwy

@bluwy bluwy commented Mar 3, 2025 •

Copy link
Copy Markdown
Member

Changes

Vite 6.2 has builtin support for treeshaking scoped CSS (vitejs/vite#19418) which we can use to replace our internal implementation copy before.

Testing

Existing tests should pass. There's added test in the past from #10291. If CI fails, maybe there's a bug in Vite.

EDIT: The new behaviour will now properly place scoped styles into its own chunk so that it's only loaded by pages that uses the component's scoped styles. This means the CSS is more granular and accurately loaded, but results in slightly more CSS chunks which causes some tests that did not anticipate it to fail. I've made fixes to the tests for these cases.

Docs

n/a. Shouldn't require a changeset as it's an internal refactor.

@changeset-bot

changeset-bot Bot commented Mar 3, 2025 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f96fb98

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 pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) labels Mar 3, 2025
@codspeed

codspeed Bot commented Mar 3, 2025 •

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #13347 will not alter performance

Comparing vite-css-scope-to (f96fb98) with main (7f596cf)

Summary

✅ 6 untouched benchmarks

@ematipico

Copy link
Copy Markdown
Member

Considering the change in behaviour, as you explained in the test section, should we make it a patch or a minor and explain the new behaviour?

Users will see more CSS files, so we should let them know about the new algorithm.

@bluwy

bluwy commented Mar 3, 2025

Copy link
Copy Markdown
Member Author

I think in most cases users wouldn't have to bother or would notice this change, so I think it's ok to not mention anything. But if we want to add a changeset, a patch should be good enough since it doesn't require a lot of action from the user.

@ematipico

ematipico commented Mar 5, 2025 •

Copy link
Copy Markdown
Member

That's true in most cases, however I've seen users complaining about chunks emitted by a change of a build. I also think few people surgically cache these kinds of assets.

So yeah, even if the majority of the users don't care, there are still few that would need an explanation of the change.

a patch should be good enough since it doesn't require a lot of action from the user.

I agree!

@ematipico ematipico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@ematipico
ematipico merged commit d83f92a into main Mar 6, 2025
@ematipico
ematipico deleted the vite-css-scope-to branch March 6, 2025 05:48
@astrobot-houston astrobot-houston mentioned this pull request Mar 6, 2025
ematipico added a commit that referenced this pull request Mar 13, 2025
#13420)

* Revert "Replace internal cssScopeTo implementation to vite.cssScopeTo (#13347)"

This reverts commit d83f92a.

* changeset

* Apply suggestions from code review
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) pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants