-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Remove unused CSS output files when inlined #8743
Conversation
🦋 Changeset detectedLatest commit: b4ef577 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 |
// CSS is already added to all used pages, we can delete it from the bundle | ||
// and make sure no chunks reference it via `importedCss` (for Vite preloading) | ||
// to avoid duplicate CSS. | ||
delete bundle[id]; |
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.
It's better to avoid delete
bundle[id] = undefined
This page contains some information about why: https://biomejs.dev/linter/rules/no-delete
I predict that doing so will trigger the TS compiler, though
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.
The convention when dealing with rollup bundles is to delete
it rather than setting it to undefined. Otherwise it kinda means that "the chunk exists but it's undefined".
+1 |
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.
This is great!
I was unsure about the timing of our "post" plugin against vite's preload plugin, but I can now see that it is "post" as well.
Tested against threlte docs as well, which is where the issue was discovered. Works perfectly!
That doesn't sound right.
You're right, the fixture does not work how I imagined. The html is not rendered either. I think what we might be noticing is that |
Sorry I messed up my wording a bit 😅 I mean CSS files not inlined to any pages should not be deleted. That was why I added the |
Changes
fix #8567
Fixes 2 issues:
importedCss
.I'm actually unsure if there's a bug in no2, where in the
css-dangling-references
fixture, the CSS is not inlined/duplicated to both the pages.Testing
The existing tests (especially
css-dangling-references
) should passDocs
n/a. bug fix.