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

[pickers] Stop root exporting locales #11612

Merged
merged 3 commits into from
Jan 15, 2024

Conversation

LukasTy
Copy link
Member

@LukasTy LukasTy commented Jan 8, 2024

Fixes #10918

  • Remove root locales re-exporting
    • import { frFR } from '@mui/x-date-pickers'; would no longer work after this, but we never endorse such usage in the docs anyway.
  • Keep root re-exporting l10n related types.
  • Re-export locales via @mui/x-date-pickers-pro/locales.

Let's review the approach, if we are fine with it, then I'll:

  • Add migration guide entry
  • Add codemod Don't see much point in having it given all circumstances

@LukasTy LukasTy added breaking change l10n localization component: pickers This is the name of the generic UI component, not the React module! v7.x labels Jan 8, 2024
@LukasTy LukasTy self-assigned this Jan 8, 2024
@mui-bot
Copy link

mui-bot commented Jan 8, 2024

Localization writing tips ✍️

Seems you are updating localization 🌍 files.

Thank you for contributing to the localization! 🎉 To make your PR perfect, here is a list of elements to check: ✔️

  • Verify if the PR title respects the release format. Here are two examples (depending if you update or add a locale file)

    [l10n] Improve Swedish (sv-SE) locale
    [l10n] Add Danish (da-DK) locale

  • Update the documentation of supported locales by running yarn l10n
  • Verify that you have added an export line in src/locales/index.ts for the new locale.
  • Run yarn docs:api which should add your new translation to the list of exported interfaces.
  • Clean files with yarn prettier.

Deploy preview: https://deploy-preview-11612--material-ui-x.netlify.app/

Updated pages:

Generated by 🚫 dangerJS against 392c310

Copy link
Member

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 10, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Member

@flaviendelangle flaviendelangle left a comment

Choose a reason for hiding this comment

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

OK to go with it since the discussion for depth 3 are far from over 👌

@flaviendelangle
Copy link
Member

We just need some migration guide and maybe codemod before merging

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 15, 2024
@LukasTy
Copy link
Member Author

LukasTy commented Jan 15, 2024

We just need some migration guide and maybe codemod before merging

I've added the migration guide entry.
WDYT about it @flaviendelangle?

I have given some thought about adding a codemod and concluded that IMHO it's not worth the effort to maybe replace 1 import for 1 in 100 user cases.
If we had encouraged using root-level imports previously, I think it could make sense to add it, but given our current documentation, I don't think it's worth it. 🤷 🙈
WDYT? 🤔

@flaviendelangle
Copy link
Member

I have given some thought about adding a codemod and concluded that IMHO it's not worth the effort to maybe replace 1 import for 1 in 100 user cases.
If we had encouraged using root-level imports previously, I think it could make sense to add it, but given our current documentation, I don't think it's worth it. 🤷 🙈
WDYT?

I'd be in favor of doing the codemod because it's fairly easy to do and adding a green check on the migration guide improves the overall feeling that the migration is easy.
But if you think it's wasted time I won't fight to have it 😆

@LukasTy
Copy link
Member Author

LukasTy commented Jan 15, 2024

I'd be in favor of doing the codemod because it's fairly easy to do and adding a green check on the migration guide improves the overall feeling that the migration is easy.

I would agree with you and kind of think that in the Data Grid case, it might make sense (however, they didn't add one, at least for now) because their demos had examples of importing locales from the root. 🤔
If I understand correctly. any new codemod means yet another iteration over every file in a given project. Because of that, in my head, it just means wasted resources and time on someone else's end. 🙈 🤷

@LukasTy LukasTy merged commit c392851 into mui:next Jan 15, 2024
17 checks passed
@LukasTy LukasTy deleted the stop-root-exporting-pickers-locales branch January 15, 2024 20:10
Comment on lines +441 to +442
- import { frFR } from '@mui/x-date-pickers';
+ import { frFR } from '@mui/x-date-pickers/locales';
Copy link
Member

Choose a reason for hiding this comment

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

Same as #11650 (comment)

Suggested change
- import { frFR } from '@mui/x-date-pickers';
+ import { frFR } from '@mui/x-date-pickers/locales';
-import { frFR } from '@mui/x-date-pickers';
+import { frFR } from '@mui/x-date-pickers/locales';

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for bringing it up.
Raised a PR fixing it and some other tiny issues. 😉
#11695

@oliviertassinari
Copy link
Member

Bundle size in https://bundlephobia.com/ is now smaller, cool

https://bundlephobia.com/package/@mui/[email protected]

https://bundlephobia.com/package/@mui/[email protected]

@LukasTy
Copy link
Member Author

LukasTy commented Jan 25, 2024

Bundle size in https://bundlephobia.com/ is now smaller, cool

Nice!. 👏
The difference on Data Grid side is even greater, because their localisation files are bigger.
Screenshot 2024-01-25 at 11 04 04

@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 25, 2024

Now, to be fair, technically, people will see an increase in v7 vs. v6 (data grid & date picker)

https://bundlephobia.com/package/@mui/[email protected]
Screenshot 2024-01-25 at 14 12 12

https://bundlephobia.com/package/@mui/[email protected]
Screenshot 2024-01-25 at 14 11 53

This is also visible when using https://marketplace.visualstudio.com/items?itemName=wix.vscode-import-cost

Still, marketing-wise, it's a win 👍 #10918 (comment)

@flaviendelangle
Copy link
Member

For the pickers, I think it's due to our double textfield approach, we bundle both the TreeView and the new component.

@oliviertassinari
Copy link
Member

Connecting this to #5550

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: pickers This is the name of the generic UI component, not the React module! l10n localization v7.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[l10n] Stop re-exporting locales from package root
5 participants