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

[core] Allow deeper import of @mui/utils #38806

Merged
merged 7 commits into from
Sep 16, 2023

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Sep 4, 2023

A quick step to illustrate my point in mui/mui-x#10215.

It's also a step toward solving #35840.

Edit: oh wow ok, looking at the source, this PR is the first time we import from a folder of @mui/utils in MUI Core. Only MUI X has been doing this so far. I guess it's why I had to change a couple of code infra files.

@mui-bot
Copy link

mui-bot commented Sep 4, 2023

Netlify deploy preview

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

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against b87e4b9

@oliviertassinari oliviertassinari force-pushed the reduce-module-imports branch 3 times, most recently from 164cdea to 833cd63 Compare September 4, 2023 21:55
@oliviertassinari oliviertassinari changed the title [core] Deeper import of modules [core] Allow deeper import of @mui/utils Sep 4, 2023
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 5, 2023
@@ -0,0 +1,15 @@
import PropTypes from 'prop-types';

declare function integerPropType(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related to the rest of this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 9, 2023
Comment on lines -70 to -76
// Begin block: Packages with files instead of packages in the top level
// Importing from the top level pulls in CommonJS instead of ES modules
// Allowing /icons as to reduce cold-start of dev builds significantly.
// There's nothing to tree-shake when importing from /icons this way:
// '@mui/icons-material/*/',
'@mui/utils/*',
// End block
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the pattern we want to allow, removing.

Comment on lines -336 to 330
// Allow deeper imports for TypeScript types. TODO?
// Allow deeper imports for TypeScript types. TODO remove
'@mui/*/*/*/*',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Types should be exposed at the same level as the other modules.

@@ -3,6 +3,7 @@
// Actual .ts source files are transpiled via babel
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": true,
Copy link
Member Author

@oliviertassinari oliviertassinari Sep 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should aim to introduce this flag on all our projects (after we deal with circular references) to speed up the build times.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I wrote a typo: with without.

@@ -0,0 +1,15 @@
import PropTypes from 'prop-types';

declare function integerPropType(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliviertassinari oliviertassinari merged commit de106f1 into mui:master Sep 16, 2023
8 checks passed
@oliviertassinari oliviertassinari deleted the reduce-module-imports branch September 16, 2023 11:49
@oliviertassinari
Copy link
Member Author

oliviertassinari commented Sep 16, 2023

This should unlock to go through the codebase to update all the imports. At which point, I think we should add an eslint rule to prevent barrel level import, and benchmark the difference, see if there is shareable material to get developers excited about.

danilo-leal pushed a commit to siriwatknp/material-ui that referenced this pull request Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants