-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Update package layout for better ESM support #43264
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy previewhttps://deploy-preview-43264--material-ui.netlify.app/ Menu: parsed: +1.74% , gzip: +1.90% Bundle size reportDetails of bundle changes (Toolpad) |
"import": "./esm/*.js", | ||
"require": "./*.js" | ||
}, | ||
"./esm/*": { |
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.
Maintain backwards compatibility for users that have done
material-ui/apps/pigment-css-vite-app/vite.config.ts
Lines 48 to 55 in 8b8732e
resolve: { | |
alias: [ | |
{ | |
find: /^@mui\/icons-material\/(.*)/, | |
replacement: '@mui/icons-material/esm/$1', | |
}, | |
], | |
}, |
|
||
const exportedNames = new Set(Object.keys(packageExports)); | ||
for (const exportedName of exportedNames) { | ||
const modernName = exportedName.replace(/^\./, legacyModernPrefix); |
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.
Maintain backwards compatibility for the legacy ./modern
bundles. Just a re-export of the main exports, but with a ./modern
prefix
closes #44055
closes #43980
Add a new mode to the build:
Notes:
./esm/*
export to icons for people who used the vite alias workaround@mui/joy/node
bundle is included in the client bundle when Joy UI component is being imported into a RSC #37934To Do:
figure out theBlocked on [core] Removeexport *
usage in files that have a'use client'
pragma.'use client'
from index files and useAutocomplete reexport #41956@mui/material-pigment-css
@mui/material-pigment-css
and@mui/icons-material
esmExternals
from the docs (investigate) [docs] Remove esmExternals from the docs #43068Bundle size increase
The bundle size increase can be fully attributed to the inclusion of the following ESM/CJS interop helper in the webpack output:
Code
This is caused by the following import
material-ui/packages/mui-system/src/useMediaQuery/useMediaQuery.ts
Line 75 in eab1b9e
A potential switch to using
use-sync-external-store
has been explored in #43476 but ultimately it makes sense to keep it, it manifests in the webpack runtime.