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

Fix resolution of @mui/material-ui in docs #43108

Merged
merged 3 commits into from
Jul 31, 2024
Merged

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Jul 29, 2024

Pulling some fixes from #43068

First problem encountered when removing esmExternals is around resolution of top level @mui/material. This was fixed by adding a new @mui/material$ alias which specifically targets this import and point it to the intended source file.

As part of this PR I'm also correcting some imports in the demos and docs modules that import the top level package

There will likely be a lot more work to get this flag removed but I'm going one-by-one. bisecting this takes a lot of time.

@Janpot Janpot added the core Infrastructure work going on behind the scenes label Jul 29, 2024
@mui-bot
Copy link

mui-bot commented Jul 29, 2024

Netlify deploy preview

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

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against c8049b7

@@ -1,8 +1,9 @@
import * as React from 'react';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { blue } from '@mui/material/colors';
import { Box, Stack } from '@mui/system';
Copy link
Member Author

Choose a reason for hiding this comment

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

Also replacing this import from @mui/system to @mui/material. This didn't seem intentional, but correct me if I'm wrong

@Janpot Janpot marked this pull request as ready for review July 29, 2024 09:59
@Janpot Janpot requested a review from DiegoAndai July 30, 2024 10:04
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

Hey @Janpot!

  • Is the top-level @mui/material import change something users should do as well? Or does it only break our repo configuration?
  • Should we add an eslint rule to avoid future imports from @mui/material?

@@ -98,8 +98,14 @@ export default withDocsInfra({
...config.resolve.alias,

// for 3rd party packages with dependencies in this repository
'@mui/material$': path.resolve(workspaceRoot, 'packages/mui-material/src/index.js'),
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused:

'@mui/material$' seems like is added to handle top-level imports from @mui/material, but we're also removing those imports in 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.

but we're also removing those imports in this PR?

Yes, but they're supposed to work, so I left this fix in

Copy link
Member

Choose a reason for hiding this comment

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

So the fix actually works but this PR includes the changed imports as they're recommended, is that correct?

Copy link
Member Author

@Janpot Janpot Jul 30, 2024

Choose a reason for hiding this comment

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

Actually, just remember I didn't remove all instances of the top-level import, only the ones in public demos as that is recommended indeed.

@Janpot
Copy link
Member Author

Janpot commented Jul 30, 2024

  • Is the top-level @mui/material import change something users should do as well? Or does it only break our repo configuration?

We're recommending it. These days, some frameworks automatically do this for you in their compilation. I'm not aware of any discussions around it, but I could see us some day even deprecate this usage.

  • Should we add an eslint rule to avoid future imports from @mui/material?

Yes, ideally.

@DiegoAndai
Copy link
Member

DiegoAndai commented Jul 30, 2024

Should we add an eslint rule to avoid future imports from @mui/material?

Yes, ideally.

Should we include it in this PR or is it out of scope?

@Janpot
Copy link
Member Author

Janpot commented Jul 30, 2024

Should we include it in this PR or is it out of scope?

I didn't remove all the top-level imports in the docs, only the ones in public demos. We can expand this override to the docs, but then we must fix all imports. Perhaps we can keep it out of scope?

@DiegoAndai
Copy link
Member

Perhaps we can keep it out of scope?

Sure 👌🏼

@Janpot Janpot merged commit 4a82b6b into mui:next Jul 31, 2024
19 checks passed
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants