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

Disallow access to esm/modern barrel files #45332

Merged
merged 3 commits into from
Feb 18, 2025
Merged

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Feb 17, 2025

  • Disallow access to ./esm/index.js and ./modern/index.js through @mui/xyz/esm and @mui/xyz/modern
  • Disallow access to @mui/icons-material/utils/createSvgIcon

@Janpot Janpot added the scope: code-infra Specific to the core-infra product label Feb 17, 2025
@mui-bot
Copy link

mui-bot commented Feb 17, 2025

Netlify deploy preview

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

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 7b5dd46

@Janpot Janpot marked this pull request as ready for review February 17, 2025 16:52
@Janpot Janpot requested a review from a team February 17, 2025 16:52
Comment on lines 159 to 166
if (!packageDataOther.exports?.['./*']) {
// From the default wildcard we should exclude the esm and modern builds.
// If you override the wildcard, you're on your own
Object.assign(packageExports, {
...createExportFor('./esm', null),
...createExportFor('./modern', null),
});
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't quite get what this means specifically.

Is it IF './*' NOT defined DISALLOW './esm' imports? Shouldn't this be disallowed for all configs regardless of wildcard? 🤔

Copy link
Member Author

@Janpot Janpot Feb 17, 2025

Choose a reason for hiding this comment

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

I just wanted to leave the developer in control. If they override the exports, we assume they know what they're doing. e.g. icons doesn't have modern exports, we shouldn't just add a "./modern": null therefore. Don't mind much either way though.

Copy link
Member

@JCQuintas JCQuintas Feb 17, 2025

Choose a reason for hiding this comment

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

Doesn't look like it would matter, as ./* and ./modern|esm are unrelated. I could override ./*. But do nothing with moder/esm

Should we check if ./modern|esm are set and warn about it or skip this change?

Copy link
Member Author

@Janpot Janpot Feb 17, 2025

Choose a reason for hiding this comment

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

Doesn't look like it would matter, as ./* and ./modern|esm are unrelated.

the "./modern": null override is there because the ./* condition would otherwise match ./modern/index.js if you do import @mui/material/modern, that's how they are related.

I could override ./*. But do nothing with modern/esm

yes, when you deviate from what this script prescribes, we give you full control. meaning: we won't override any paths that you expect to be working.

Should we check if ./modern|esm are set and warn about it or skip this change?

If they are set, they will override the default of null in the subsequent lines.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the info. I'm not familiar with this script 🙃

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to rework it a bit to better reflect the intention

@Janpot Janpot enabled auto-merge (squash) February 18, 2025 11:22
@Janpot Janpot merged commit 776b9c6 into mui:master Feb 18, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: code-infra Specific to the core-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants