-
-
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
[code-infra] Inject display name #44067
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy previewhttps://deploy-preview-44067--material-ui.netlify.app/ @material-ui/core: parsed: +0.18% , gzip: +0.13% Bundle size reportDetails of bundle changes (Toolpad) |
packages-internal/scripts/typescript-to-proptypes/src/injectPropTypesInFile.ts
Outdated
Show resolved
Hide resolved
packages-internal/scripts/typescript-to-proptypes/src/injectPropTypesInFile.ts
Outdated
Show resolved
Hide resolved
@@ -167,4 +167,6 @@ Button.propTypes /* remove-proptypes */ = { | |||
to: PropTypes.string, | |||
} as any; | |||
|
|||
Button.displayName = 'Button'; |
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.
What about?
Button.displayName = 'Button'; | |
if(process.env.NODE_ENV !== 'production') { | |
Button.displayName = 'Button'; | |
} |
this would mean:
- be sure there is no regressions
- give developers developer confidence that this isn't going to bloat their bundle
- In the code ejection story, we could automatically wrap this, but I would expect people to also copy and paste the source too
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.
I thought about it but went for the current solution because
- Parity with the proptypes generation. Both work the exact same way: upsert code => wrap in build step. If you understand one, you also understand the other. If we add in the conditional for displayName, then I think we should do the same for
propTypes
and remove the babel plugin. - It's more straightforward and robust for the detection logic if it consists of a single top-level statement statement.
- It prevents people from getting tempted adding more things in the coditional. Which in turn would either break the detection logic, or make it much more complex.
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.
Parity with the proptypes generation
Ah right ok, I forgot, I thought we were doing the opposite. Makes sense then 👍
…opTypesInFile.ts Co-authored-by: Olivier Tassinari <[email protected]> Signed-off-by: Jan Potoms <[email protected]>
…opTypesInFile.ts Co-authored-by: Olivier Tassinari <[email protected]> Signed-off-by: Jan Potoms <[email protected]>
Should this be a babel plugin instead? Do we need to commit these changes? 🤔 |
Implements mui/mui-public#209 to stabilise tests and improve DX
Individual commits for easier review: