Skip to content

[code-infra] Always enforce consistent-type-imports#1357

Merged
Janpot merged 5 commits into
masterfrom
feat/default-consistent-type-imports
Apr 30, 2026
Merged

[code-infra] Always enforce consistent-type-imports#1357
Janpot merged 5 commits into
masterfrom
feat/default-consistent-type-imports

Conversation

@JCQuintas
Copy link
Copy Markdown
Member

Summary

Make @typescript-eslint/consistent-type-imports (fixStyle: 'inline-type-imports') part of the shared base ESLint config — always on, no opt-in flag.

Why

Type-only imports get erased at compile time, so they never reach a downstream bundler. A value-import that references a TypeScript-only name (e.g. import { Theme } from '@mui/material/styles') survives the build and trips strict bundlers:

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

Vite 8 / Rolldown surfaces this as a hard error (Rollup tolerated it). We hit this in mui/mui-x#22260 while bundling MUI X regression tests — the failing import lives in @mui/internal-core-docs. The single-package fix is in mui/material-ui#48386 (originally also added a per-package ESLint override there); per @Janpot's suggestion we move that override into the shared config so the rule applies everywhere.

Changes

  • packages/code-infra/src/eslint/baseConfig.mjs: drop the consistentTypeImports parameter; the rule is always applied.
  • packages/code-infra/src/eslint/mui/config.mjs: same — remove conditional, hardcode the rule with a comment explaining the bundler-strictness motivation.

Downstream

Consumers (mui/material-ui, mui/mui-x, mui/base-ui, …) will pick up the rule automatically when they bump @mui/internal-code-infra. They will need to either run the autofix or accept the inline type modifier across their codebases. Because fixStyle is inline-type-imports, the autofix is non-disruptive.

@JCQuintas JCQuintas self-assigned this Apr 29, 2026
@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented Apr 29, 2026

Deploy preview

https://deploy-preview-1357--mui-internal.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)

Details of bundle changes

Performance

Total duration: 16.47 ms +0.62 ms(+3.9%) | Renders: 4 (+0) | Paint: 69.40 ms +2.46 ms(+3.7%)

Test Duration Renders
HeavyList mount 10.05 ms 🔺+0.37 ms(+3.8%) 1 (+0)
DataGrid mount with paint timing 2.20 ms 🔺+0.23 ms(+11.7%) 1 (+0)
Counter click 4.22 ms 🔺+0.02 ms(+0.5%) 2 (+0)

details


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

JCQuintas added a commit to JCQuintas/material-ui that referenced this pull request Apr 29, 2026
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

@Janpot I suppose you meant removing the option in order to force it globally?

@oliviertassinari oliviertassinari temporarily deployed to feat/default-consistent-type-imports - code-infra-dashboard PR #1357 April 29, 2026 14:48 — with Render Destroyed
@oliviertassinari oliviertassinari temporarily deployed to feat/default-consistent-type-imports - mui-tools-public PR #1357 April 29, 2026 14:48 — with Render Destroyed
@Janpot Janpot added the breaking change Introduces changes that are not backward compatible. label Apr 29, 2026
@Janpot
Copy link
Copy Markdown
Member

Janpot commented Apr 29, 2026

per @Janpot's suggestion we move that override into the shared config so the rule applies everywhere.

Nuance, it was just a question 😬. By no means did I volunteer the code infra team to own this change across all projects. But I don't mind adding an opt-in for it in the config factory so you can propagate it gradually across all repos.

Let's build a good case to motivate this update. Can you put together a small code example that our build tool produces output for that is not consumable by vite 8?

@JCQuintas
Copy link
Copy Markdown
Member Author

per @Janpot's suggestion we move that override into the shared config so the rule applies everywhere.

Nuance, it was just a question 😬. By no means did I volunteer the code infra team to own this change across all projects. But I don't mind adding an opt-in for it in the config factory so you can propagate it gradually across all repos.

It was already an option though 😆

f80a02a

@JCQuintas
Copy link
Copy Markdown
Member Author

Let's build a good case to motivate this update. Can you put together a small code example that our build tool produces output for that is not consumable by vite 8?

My issue is that we would require it to support vite v8.

In https://github.com/mui/mui-x/pull/22243/changes I need to keep two versions of vite. v7 for regular codebase, and v8 for the performance tests due to vite 8 using rolldown instead of rollup.

This PR is not really required though. As we could simply apply that to the offending package, which is packages-internal/core-docs in mui/material-ui#48386

@Janpot
Copy link
Copy Markdown
Member

Janpot commented Apr 30, 2026

Ok, so we see for instance in the diff that the Theme type-only import gets stripped from the ESM source after we correctly annotate it with type. It's clear that the annotation is necessary for our type stripping compiler to function correctly. It looks from that diff like it could have a non-zero effect on our bundle size. eslint auto-fix will take care of the ergonomics. we will roll this out across the company.

@Janpot
Copy link
Copy Markdown
Member

Janpot commented Apr 30, 2026

It was already an option though 😆

The option is exactly there to allow for gradually rolling it out across the company. "Rolling it out" means "enable the flag on every repo", not "remove the flag". Reverting those changes to the flag and setting the option instead in our config.

@Janpot Janpot merged commit b5ecb08 into master Apr 30, 2026
13 checks passed
@Janpot Janpot deleted the feat/default-consistent-type-imports branch April 30, 2026 08:41
@zannager zannager added the scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). label Apr 30, 2026
Copilot AI pushed a commit that referenced this pull request May 4, 2026
Co-authored-by: Janpot <2109932+Janpot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible. scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants