-
-
Notifications
You must be signed in to change notification settings - Fork 168
Fix CSS import queries (?url, ?inline, ?raw) being incorrectly collected in RSC plugin #579
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
Conversation
?url
?inline
?raw
* Check if a CSS import ID has special queries that should be excluded from CSS collection. | ||
* These queries transform CSS imports to return different data types rather than actual CSS to be linked. | ||
*/ | ||
function hasSpecialCssQuery(id: string): boolean { |
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.
remove trivial unit tests. add e2e instead by updating examples/basic
and e2e/basic.test.ts
.
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.
Done! I've removed the trivial unit tests and replaced them with e2e tests. Added CSS query test components to examples/basic
and comprehensive e2e tests in basic.test.ts
that verify both the functional behavior and SSR CSS collection. (0f6af41)
Co-authored-by: hi-ogawa <[email protected]>
@@ -0,0 +1,23 @@ | |||
'use client' |
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.
add test for server component too
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.
Added server component test! Created TestCssQueriesServer
component in server.tsx
that tests the same CSS import scenarios as the client component. Also updated the e2e tests to verify both client and server component behavior. (8e97c2b)
I also tested Claude code and it was easier to iterate. Closing in favor of #580 |
Problem
CSS imports with special queries like
?url
,?inline
, and?raw
were being incorrectly included in CSS collection for server-side rendering in the RSC plugin. These queries transform CSS imports to return different data types rather than actual CSS that should be linked in documents.Solution
Modified the
collectCss
function inpackages/plugin-rsc/src/plugin.ts
to filter out CSS imports with special queries:hasSpecialCssQuery()
helper function that detects imports with?url
,?inline
, or?raw
queriesImplementation Details
Testing
This aligns with standard practices used by other frameworks like SvelteKit and ensures CSS collection works correctly for RSC server-side rendering.
Fixes #571.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.