-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[l10n] Stop re-exporting locales
from package root
#10918
Comments
I'm wondering if it's worth doing this before we provide an actual good solution to avoid bundling all locales in anyone bundle (in dev). With this change, people using the default locale won't bundle the locales in dev mode, Today: Would it be better for our community to release the new endpoint before removing the root export? I know that One could even wonder if removing it is useful, since people can import everything without ever using the root import. |
@flaviendelangle I'm not sure we need to move towards allowing only direct locale imports. The main benefit that they reap and we want to benefit as well is the de-inflation of the bundle size. As @oliviertassinari noted, he would not be in favor of adding an exception allowing 3rd-level importing only for locales. |
We have a broader topic here that I briefly discussed with @oliviertassinari a few weeks ago. import { DatePicker } from '@mui/x-date-picker/joy'
import { DatePicker } from '@mui/x-date-picker/material'
import { DatePicker } from '@mui/x-date-picker/base' But once we have that, do we drop the support for nested imports or do we allow the following: import { DatePicker } from '@mui/x-date-picker/joy/DatePicker' If we drop the support for nested imports, then for me it's coherent to also not support it for the locales and only have But if we want to support it, then we end up in a situation with only a few folders in the package and imports of depth 3 allowed. For me both make sense and both end up with consistent results which is the most important outcome here. |
It might be OK. It's a relatively small package: https://bundlephobia.com/package/@mui/x-date-pickers@6.19.0. I imagine that once we remove the locales, from the entry point, it will be even smaller.
For me, the main problem is to educate users about what's a private module and what's a public one. Today private is deep import with depth >= 3, very simple. If we can get the same outcome with exports, then why not: ![]() |
locales
from package rootlocales
from package root
locales
from package rootlocales
from package root
I have added a Why section to this issue description. We are not doing this change for technical reasons but for marketing ones. It's about not being at a disadvantage for developers who don't understand tree-shaking and comparing us to other libraries. Technically, bundle size stays the same, developers who care about build speed (and are not on Next.js) can continue to import modules one level deep. The only price we have to pay is a small surprise to not being able to import from the top level. We are using the same tradeoff with Material UI, proof, https://bundlephobia.com/package/@mui/material@5.15.6. So it's also more consistent MUI-wise. |
We currently re-export locales from in the root
index
file so that they are available from bothimport { frFR } from '@mui/x-date-pickers/locales'
andimport { frFR } from '@mui/x-date-pickers'
.mui-x/packages/x-date-pickers/src/index.ts
Line 8 in 947619d
We should avoid root-level exporting as it doesn't solve any particular problem besides making the package seem bulkier.
Search keywords:
Why?
It's for marketing reasons (meaning perceived value, which is not the same as real value). See in mui/material-ui#39525
The text was updated successfully, but these errors were encountered: