Skip to content
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

Merged
merged 2 commits into from
Feb 6, 2024
Merged

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Jan 26, 2024

Using webpack aliases instead. This avoids having to run these packages through babel

@Janpot Janpot added the docs Improvements or additions to the documentation label Jan 26, 2024
@mui-bot
Copy link

mui-bot commented Jan 26, 2024

Netlify deploy preview

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

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against dd33142

@danilo-leal danilo-leal added the scope: code-infra Specific to the core-infra product label Jan 26, 2024
@Janpot Janpot marked this pull request as ready for review February 1, 2024 10:42
@Janpot Janpot requested a review from a team February 1, 2024 10:43
Copy link
Member

@michaldudak michaldudak left a 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 :)

@Janpot Janpot merged commit 8cf92b8 into mui:master Feb 6, 2024
23 checks passed
Comment on lines -127 to -128
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)/,
Copy link
Member

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.

Copy link
Member Author

@Janpot Janpot Feb 7, 2024

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.

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation scope: code-infra Specific to the core-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants