[code-infra][icons-material] Avoid material utils barrel in createSvg…#48029
[code-infra][icons-material] Avoid material utils barrel in createSvg…#48029Janpot merged 7 commits intomui:masterfrom
Conversation
Netlify deploy previewhttps://deploy-preview-48029--material-ui.netlify.app/ Bundle size report
|
|
To avoid duplication you can export |
Thanks, that makes sense. I updated the PR in that direction.
|
There was a problem hiding this comment.
why did the quotes change? Did you edit this file manually? It should be generated from ./packages/mui-icons-material/src/utils/createSvgIcon.js
There was a problem hiding this comment.
Good catch.
That quote/style change was just generated-artifact drift after the refactor. I’ve regenerated packages/mui-icons-material/lib/utils/createSvgIcon.{js,mjs} so the tracked lib files match the build output again.
The actual change is only the helper re-export path in the source.
There was a problem hiding this comment.
I think we can drop the lint rule. Bit too much duplication, these restricted imports are already hard to manage. Instead, just add a @deprecated jsdoc comment on the @mui/material/utils/createSvgIcon export.
There was a problem hiding this comment.
That makes sense to me.
I dropped the lint rule and added @deprecated markers to the compatibility re-export in:
packages/mui-material/src/utils/createSvgIcon.jspackages/mui-material/src/utils/createSvgIcon.d.ts
The actual helper path remains on @mui/material/SvgIcon.
eslint.config.mjs
Outdated
| }, | ||
| }, | ||
| { | ||
| files: [`packages/mui-icons-material/src/**/*${EXTENSION_TS}`], |
There was a problem hiding this comment.
Isn't this already covered by https://github.com/anchmelev/material-ui/blob/8d187b6a70171a82a64e3c9c640d4abea767855a/eslint.config.mjs#L245-L267. I think you can restore the eslint configuration.
There was a problem hiding this comment.
You're right - packages//src/**/ already covers mui-icons-material. I restored it!
| @@ -1,2 +1 @@ | |||
| 'use client'; | |||
There was a problem hiding this comment.
You can keep the 'use client' for now
There was a problem hiding this comment.
Restored 'use client' in src/utils/createSvgIcon.js and synced the generated lib helpers so they match the rest of the package.
|
Thank you! |
Part of #35840
Summary
createSvgIconin@mui/icons-materialso it no longer re-exports from@mui/material/utils@mui/material/SvgIcon@mui/icons-material/*type path remains intact@mui/material/utilsout ofpackages/mui-icons-material/srcWhy
A single icon import currently goes through the Material utils barrel:
@mui/icons-material/AbcRounded->./utils/createSvgIcon->@mui/material/utilsThat pulls extra modules into the dependency graph for an icon hot path. This PR keeps the scope intentionally small and only removes that barrel path from
@mui/icons-material.Because
@mui/icons-material/*resolves throughlib/*.mjsin this repo, the local helper also needs generated declarations to preserve the previous type behavior.Benchmark
Standalone webpack check for
AbcRounded:268modules229modules-39modules (-14.6%)Verification
pnpm -F @mui/icons-material build:typings✅pnpm --filter docs typescript✅pnpm -F @mui/icons-material test✅