-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[code-infra] Extract Babel macro from mui-utils #40262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Netlify deploy previewhttps://deploy-preview-40262--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like an improvement as well.
I think there is a test somewhere that checks whether these macro imports appear in the build output, at which point it errors. Does that still work? (I may be hallucinating this)
I haven't found anything like this (I checked all occurrences of "macro" and "MuiError" in the codebase). |
@mui/x, I found one reference to the macro: https://github.dev/mui/mui-x/blob/d7149efe21b3b43f76fbf65aa35c499a7861d590/docs/babel.config.js#L41 |
😆 Wow this replacement is weird, no idea why it's here |
Unfortunately, there's no word of explanation. |
🤷 Yes, it's a mistery |
Yep, we had this in Toolpad for a while after copying the setup from X. I remember asking @oliviertassinari about it once. I couldn't figure out what the sense in it was so I removed it on our side. I'd say remove it, and if that breaks something let's figure out a better solution. |
As I recall about this, the idea was to have an import that works, I used react as I could have used something random, I assumed errors will normally not throw. |
I moved the MuiError Babel macro to its own package, so @mui/utils contain only run-time (not build-time logic).
This is necessary for the pnpm migration, as we would like to link build outputs between workspace projects (as opposed to sources, like it's done today). Bundlers and other tools will use Babel/Webpack/TS aliases to resolve the sources, but it was proven to be problematic in the case of the macro (somehow aliases did not apply there).