[core-infra] Remove useless fragments#44516
Conversation
831073b to
c35a00d
Compare
Netlify deploy previewhttps://deploy-preview-44516--material-ui.netlify.app/ PigmentHidden: parsed: +2.29% , gzip: +2.84% Bundle size reportDetails of bundle changes (Toolpad) |
36103ee to
16b8868
Compare
| const filename = componentInfo.filename; | ||
| let reactApi: ComponentReactApi; | ||
|
|
||
| if (componentInfo.isSystemComponent || componentInfo.name === 'Grid2') { |
There was a problem hiding this comment.
That hard-coded logic felt wrong, we further added stuff around it in 08dce48#diff-eef575d465fe9894710e7eb399c76ad3e3900a8cbb6d374be7f303c4b6c6ef51R627
romgrk
left a comment
There was a problem hiding this comment.
LGTM overall but I don't think I'm the right person to review this, I have barely touched the docs & mui-material (unlike mui-system).
|
It's related to code-infra, right, I wasn't sure who to ask. This will impact Base UI too, e.g. we should be able to simplify NoSsr implementation. Let's ask Michal for a review, I guess it's the closest. |
michaldudak
left a comment
There was a problem hiding this comment.
Nice, this looks good. I ran docs:api with this code in the Base UI repo and didn't get any changes in generated files, so I assume it works as correctly as before.
|
Great. Next, it's about:
Right now: https://unpkg.com/browse/@mui/material@6.1.9/NoSsr/NoSsr.js It should be a small win with bundle size: - // We need the Fragment here to force react-docgen to recognise NoSsr as a component.
- return /*#__PURE__*/_jsx(React.Fragment, {
- children: mountedState ? children : fallback
- });
+ return mountedState ? children : fallback; |
I'm having some fun with the AST, allowing https://github.com/reactjs/react-docgen to extract props descriptions even when the component doesn't return a React element. We shouldn't be shipping dead code to developers, this PR avoids this. This should both improve bundle size and runtime.
DefinitelyTyped/DefinitelyTyped#65135 should help in the future.