Skip to content

feat(css): declare style module sizes to Rolldown - #24230

Open
hyfdev wants to merge 2 commits into
vitejs:mainfrom
hyfdev:feat/css-declared-module-size
Open

hyfdev wants to merge 2 commits into
vitejs:mainfrom
hyfdev:feat/css-declared-module-size

Conversation

@hyfdev

@hyfdev hyfdev commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Rolldown's size checks, such as experimentalInlineCommonChunks.maxSize, count a CSS module as only its small JS stub.

This PR declares the real size, the JS plus the extracted CSS, through Rolldown's declaredModuleSize (rolldown/rolldown#11844, in Rolldown 1.3.4).

With two entries that share 333 bytes of CSS and maxSize: 256:

  • Before: the shared chunk is inlined into both entries, so both stylesheets contain the shared CSS.
  • After: the shared chunk stays separate, and its CSS is emitted once.

The size is declared only when cssCodeSplit and emitAssets are on and the CSS is not ?inline.

Expected behavior:

  • The size is measured before minification.
  • With cssScopeTo, the declared size is the whole CSS, even if part of it is trimmed.
  • If a size condition moves CSS into a group's stylesheet, the order of CSS rules can change.
  • With IIFE or UMD output, a size group that now matches can need a second chunk, and the build fails with INVALID_OPTION. I'm not handling that here.

@hyfdev

hyfdev commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

CI is red because Vite doesn't build with Rolldown 1.3.4 yet.

Rolldown removed skipCommonRuntimeInjection and optimizeModulePreloadRelativePaths, and changed a SourceMap type.

The bump commit is only here to get declaredModuleSize.

@hyfdev
hyfdev marked this pull request as ready for review November 27, 2026 04:25
Copilot AI balanced review requested due to automatic review settings November 27, 2026 04:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@sapphi-red sapphi-red added feat: css p3-significant High priority enhancement (priority) labels Nov 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: css p3-significant High priority enhancement (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants