-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[code-infra] Remove babel alias from the docs #40792
Conversation
Netlify deploy previewhttps://deploy-preview-40792--material-ui.netlify.app/ Bundle size report |
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.
Always good to see code removed :)
include: | ||
/node_modules(\/|\\)(notistack|@mui(\/|\\)x-data-grid|@mui(\/|\\)x-data-grid-pro|@mui(\/|\\)x-license-pro|@mui(\/|\\)x-data-grid-generator|@mui(\/|\\)x-date-pickers-pro|@mui(\/|\\)x-date-pickers|@mui(\/|\\)x-charts|@mui(\/|\\)x-tree-view)/, |
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.
I believe we need to transpile Data Grid, Date Picker, Tree View because when we make a change in Material UI, that could impact these components, the sooner we know it, the better. We started doing this with #13685.
Does this behavior still happen? Yes, it looks like so 👍 : hasDependencyOnRepoPackages
+ webpack alias doing the job.
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.
Yes, we were aliasing in babel, meaning we had to transpile these packages to apply the aliasing. Babel is the wrong place to do this, because it only operates on a subset of the files. You may end up with half your bundle with aliases applied and half without.
webpack acts as a linker, it connects all the imports together. When we alias a dependency in webpack it applies to every import, regardless of whether it ran through babel. It's a lot less error-prone to do it in this phase, and a lot less wasteful.
If we weren't transpiling these files for any other reason than applying the alias, we can simply stop transpiling them.
Everywhere I can I will remove the aliasing from babel. It simply doesn't belong there. aliasing is a linker concern. babel has no notion of this phase, it operates on individual files only.
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.
If we weren't transpiling these files for any other reason than applying the alias, we can simply stop transpiling them.
I don't recall a reason to transpile npm dependencies other than to change the imports.
Using webpack aliases instead. This avoids having to run these packages through babel