-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(nuxt): clear previous head in island-renderer #32100
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
|
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.
Pull Request Overview
This PR fixes an issue with head management in Nuxt's island-renderer by ensuring that previously registered head entries are completely cleared. Key changes include:
- Replacing the deprecated splice method with a clear() call to reset head entries.
- Adding a test to verify that styles added via plugins are not re-applied in server-rendered output.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
test/basic.test.ts | Adds a test to assert that plugin-provided head styles are not rendered |
packages/nuxt/src/app/components/island-renderer.ts | Replaces array splice with clear() to properly reset head entries |
Comments suppressed due to low confidence (2)
test/basic.test.ts:2046
- [nitpick] Consider adding further assertions to confirm that other head entries remain intact after clearing to ensure no unintended side effects occur.
// head set using plugins should not be added again
packages/nuxt/src/app/components/island-renderer.ts:21
- Ensure that head.entries is always defined before calling clear() to avoid potential runtime errors if the injected head does not implement a clear() method.
head.entries.clear()
WalkthroughThe changes revise the clearing of head entries in the IslandRenderer component by replacing array splicing with a direct call to clear the entries collection. In the test suite, the expected page title was updated from including a suffix to a simpler form, and additional assertions were added to verify that a CSS style injected by a plugin is present in the server-rendered HTML. Several snapshot expectations related to Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@nuxt/kit
nuxt
@nuxt/schema
@nuxt/rspack-builder
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #32100 will not alter performanceComparing Summary
|
f69363c
to
fc14617
Compare
🔗 Linked issue
📚 Description
This bug has been mentioned multiple times, such as in this comment. Essentially, the logic for clearing entries in head used a deprecated method that didn't function properly.
As a result, every server component in project that uses @nuxt/ui includes the entire css variables declaration, significantly impacting performance. The difference is striking: current code, the head size is 7778 bytes; after my changes, it's only 394 bytes—nearly a 20x difference, for a very simple markdown component.