Skip to content

[core-docs] Use type-only imports for type-only references#48386

Merged
JCQuintas merged 4 commits intomui:masterfrom
JCQuintas:fix/branding-theme-type-imports
Apr 30, 2026
Merged

[core-docs] Use type-only imports for type-only references#48386
JCQuintas merged 4 commits intomui:masterfrom
JCQuintas:fix/branding-theme-type-imports

Conversation

@JCQuintas
Copy link
Copy Markdown
Member

@JCQuintas JCQuintas commented Apr 29, 2026

Summary

Vite 8 uses Rolldown (instead of Rollup) for production builds. Rolldown is stricter than Rollup about value-imports that reference names with no runtime export — it fails the build with a MISSING_EXPORT error.

Several files in @mui/internal-core-docs import types such as Theme, ThemeOptions, SxProps from @mui/material/styles and @mui/system as plain (value) imports. Babel happens to keep some of those at compile time, and they then reach the bundler. With Rollup this was fine; with Rolldown the bundle fails:

[MISSING_EXPORT] Error: "Theme" is not exported by "@mui/material/styles/index.mjs"

This was hit while bundling MUI X regression tests with vite 8 (mui/mui-x#22260).

Changes

Convert all type-only references in packages-internal/core-docs/src/** to use the inline type modifier (or import type) so they are erased at compile time and never reach the bundler.

The per-package ESLint override was moved to mui/mui-public#1357 so the rule applies to every consumer.

Vite 8 uses Rolldown for production builds, which is stricter than Rollup
about value-imports referencing names that have no runtime export.
Several files import types like Theme, ThemeOptions, SxProps as
value-imports from @mui/material/styles or @mui/system; Rolldown then
fails with "X is not exported by ..." because those names exist only
in declaration files.

Add the inline `type` modifier (or use `import type`) so the imports
are erased at compile time and never reach the bundler.
@JCQuintas JCQuintas added the scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). label Apr 29, 2026
@JCQuintas JCQuintas self-assigned this Apr 29, 2026
@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented Apr 29, 2026

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Deploy preview

https://deploy-preview-48386--material-ui.netlify.app/


Check out the code infra dashboard for more information about this PR.

@JCQuintas JCQuintas requested a review from a team April 29, 2026 13:50
@Janpot
Copy link
Copy Markdown
Member

Janpot commented Apr 29, 2026

Time to make this a company wide setting?

@JCQuintas
Copy link
Copy Markdown
Member Author

Up to you, might anger some ppl 😆

mui/mui-public#1357 makes consistent-type-imports always-on in the shared
base config, so the per-package override here would become redundant
once material-ui bumps @mui/internal-code-infra.
@JCQuintas
Copy link
Copy Markdown
Member Author

Moved to mui/mui-public#1357 — making it the default in the shared config so it covers every consumer.

Copy link
Copy Markdown
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Ok, let's merge this, and then migrate the rest of the repo in a separate PR

@JCQuintas JCQuintas merged commit 39ea7d3 into mui:master Apr 30, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants