-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Conversation
Netlify deploy previewhttps://deploy-preview-45332--material-ui.netlify.app/ Bundle size report |
scripts/copyFilesUtils.mjs
Outdated
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), | ||
}); | ||
} |
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 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? 🤔
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 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.
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.
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?
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.
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 withmodern/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.
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.
Thanks for the info. I'm not familiar with this script 🙃
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'm going to rework it a bit to better reflect the intention
./esm/index.js
and./modern/index.js
through@mui/xyz/esm
and@mui/xyz/modern
@mui/icons-material/utils/createSvgIcon