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

[core] Remove warning message in production #13911

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Jul 20, 2024

Same as #12992.

Before

All of these warnings do nothing in production mode, and yet, they are sent to the client:

SCR-20240720-lqjz

"the value of a field is an object" https://mui.com/x/react-data-grid/

It was also possible to solve this problem with const valueError = /*#__PURE__*/ buildWarning( demo but this seems to be a really painful DX. For example, how do you add tests for the warning DX? You need to rest the warnOnce cache between each test, ouch.

After

This seems to save 2kB gzipped comparing https://deploy-preview-13911--material-ui-x.netlify.app/x/react-data-grid/ to https://deploy-preview-13910--material-ui-x.netlify.app/x/react-data-grid/, a good win in absolute terms. Now, 2kB out of 748kB on the page, it's not a big win in relative terms, but why is there so much JavaScript loaded in the first place.


Off-topic. On code infra. In Base UI, Material UI, we have relied on propTypes as much as possible for those warnings because they have the warn once logic built-in and give you the React tree trace. But, we couldn't always do this, we added simple console.error / console.warn. Now, those are missing a "warn once" logic, so I think that eventually, we should move this warnOnce() helper to @base_ui/internals.

cc @Janpot @michaldudak


It also relates to #5550 and https://www.notion.so/mui-org/Community-surveys-12055ef9657f44b5a449c9547c96bfcb?pvs=4#c40ab63b5810454193b02ca4b32f6458 around trying to be as lean as possible.
It's also related to developers often saying: "this is over-engineered, I don't want this", e.g. on React Aria. Meaning, I don't want you to support use cases A, B, C, you should have said no to the person who asked.

@mui-bot
Copy link

mui-bot commented Jul 20, 2024

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

Generated by 🚫 dangerJS against a887c7b

@oliviertassinari oliviertassinari force-pushed the bundle-size-warning branch 7 times, most recently from 53b6b31 to 7ef9173 Compare July 20, 2024 19:26
@oliviertassinari oliviertassinari merged commit 46c6d1b into mui:master Jul 22, 2024
17 checks passed
@oliviertassinari oliviertassinari deleted the bundle-size-warning branch July 22, 2024 12:11
@oliviertassinari oliviertassinari added the core Infrastructure work going on behind the scenes label Jul 22, 2024
DungTiger pushed a commit to DungTiger/mui-x that referenced this pull request Jul 23, 2024
joserodolfofreitas pushed a commit to joserodolfofreitas/material-ui that referenced this pull request Jul 29, 2024
thomasmoon pushed a commit to thomasmoon/mui-x that referenced this pull request Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants