-
-
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
[core-infra] Remove useless fragments #44516
[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
@@ -628,58 +628,59 @@ export default async function generateComponentApi( | |||
const filename = componentInfo.filename; | |||
let reactApi: ComponentReactApi; | |||
|
|||
if (componentInfo.isSystemComponent || componentInfo.name === 'Grid2') { |
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.
That hard-coded logic felt wrong, we further added stuff around it in 08dce48#diff-eef575d465fe9894710e7eb399c76ad3e3900a8cbb6d374be7f303c4b6c6ef51R627
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.
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. |
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.
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/[email protected]/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.