Repository navigation
fix(vite): drop duplicate CSS links for fully inlined shared chunks - #36056
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe SSR styles plugin now records client module importers and maps emitted CSS filenames to their source modules. Manifest cleanup tracks CSS consumers and removes stylesheet links only when every importer path inlines the CSS, including shared and source-less chunks. Client bundle processing builds these maps before returning. Tests cover shared CSS retention and Mergeability Score: 🔵 Low · up to The PR removes duplicate CSS links for fully inlined shared chunks. A bounded merge-readiness risk remains because the tests may not detect cases where styles are both inlined and linked; merge is reasonable with explicit follow-up to assert that duplicate links are absent. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/vite/src/plugins/ssr-styles.ts`:
- Around line 136-137: Update the shared-chunk cleanup around cssSources and the
allInlined/inlinedCSSModuleIds logic so inlining state is tracked per manifest
consumer or entry rather than globally. When nuxt.options.features.inlineStyles
is function-valued, conservatively skip this cleanup to prevent one consumer’s
decision from removing CSS needed by another. Add a regression fixture where the
predicate returns different results for consumers.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 86587f04-dce1-448d-82ef-327daa47b001
📒 Files selected for processing (2)
packages/vite/src/plugins/ssr-styles.tstest/inline-styles.test.ts
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/vite/src/plugins/ssr-styles.ts`:
- Around line 107-113: Update the CSS source aggregation near the mapping logic
at lines 287-290 to merge each chunk’s source IDs into the existing set for a
CSS filename instead of overwriting it. In isDroppableCSSFile, treat a missing
source mapping as non-droppable by returning false, while preserving the
existing all-importers-inlined check for present source sets.
In `@test/inline-styles.test.ts`:
- Around line 54-61: Strengthen the inline-styles tests by separating
inline-style content from linked stylesheet content: in the retain-linked-CSS
test, assert the token is absent from inline styles and cssLinks is non-empty
before checking linked files; in the opted-in predicate test, assert cssLinks is
empty while preserving its inline-token assertion. Reuse the file’s existing
style and link extraction helpers or patterns.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 75354c81-e154-4642-bf5e-650a53c63e2d
⛔ Files ignored due to path filters (2)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yamltest/fixtures/inline-styles-predicate/package.jsonis excluded by!**/package.json
📒 Files selected for processing (13)
packages/vite/src/plugins/ssr-styles.tstest/fixtures/inline-styles-predicate/app.vuetest/fixtures/inline-styles-predicate/assets/shared.csstest/fixtures/inline-styles-predicate/components/SharedBox.vuetest/fixtures/inline-styles-predicate/nuxt.config.tstest/fixtures/inline-styles-predicate/pages/inlined.vuetest/fixtures/inline-styles-predicate/pages/not-inlined.vuetest/fixtures/inline-styles-predicate/tsconfig.jsontest/fixtures/inline-styles/assets/shared-with-js-module.csstest/fixtures/inline-styles/components/shared-css-module.jstest/fixtures/inline-styles/pages/shared-css-direct.vuetest/fixtures/inline-styles/pages/shared-css-via-js.vuetest/inline-styles.test.ts
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Strengthen the stylesheet-link assertions.
At Lines 54-61, the test searches the document HTML and linked files as one string. It passes when the CSS is inlined and cssLinks is empty. It also passes when the CSS is both inlined and linked.
At Lines 138-142, the opted-in predicate test only checks for the token in inline styles. It does not verify that the stylesheet link was removed.
When the page must retain linked CSS, assert that the token is absent from inline styles and that cssLinks is non-empty before checking the linked files. When the page must fully inline CSS, assert that cssLinks is empty.
Suggested assertion changes
- expect([html, ...linked].join('\n')).toContain('--inline-shared-with-js-module-token:shared-with-js-module')
+ expect(inlinedStyles).not.toContain('--inline-shared-with-js-module-token:shared-with-js-module')
+ expect(cssLinks.length).toBeGreaterThan(0)
+ expect(linked.join('\n')).toContain('--inline-shared-with-js-module-token:shared-with-js-module')
expect(inlinedStyles).toContain('--inline-predicate-shared-token:predicate-shared')
+ expect(cssLinks).toEqual([])Reuse the existing style and link extraction patterns in this file.
Also applies to: 138-142
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/inline-styles.test.ts` around lines 54 - 61, Strengthen the
inline-styles tests by separating inline-style content from linked stylesheet
content: in the retain-linked-CSS test, assert the token is absent from inline
styles and cssLinks is non-empty before checking linked files; in the opted-in
predicate test, assert cssLinks is empty while preserving its inline-token
assertion. Reuse the file’s existing style and link extraction helpers or
patterns.

🔗 Linked issue
resolves #35255
related #30435, #34950, #34008, #35649
📚 Description
this allows shared chunks to be stripped (issue is that shared rolldown chunks have no
facadeModuleId).