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] Test some TypeScript perf optimizations #32571
[core] Test some TypeScript perf optimizations #32571
Conversation
@material-ui/core: parsed: +20.74% , gzip: +11.72% |
We probably will need to increase a bit more the |
…that extends ButtonBase - it is redundant
@@ -3,13 +3,7 @@ | |||
"children": { "type": { "name": "node" } }, | |||
"classes": { "type": { "name": "object" } }, | |||
"expandIcon": { "type": { "name": "node" } }, | |||
"focusVisibleClassName": { "type": { "name": "string" } }, | |||
"sx": { |
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.
The sx
prop here is basically duplicated type, as it is already defined in the ButtonBase
. We can rely on the link towards the ButtonBase
for documentation on the sx prop.
a4a3c0d
to
ea1f246
Compare
Good job so far! |
I will close this one and open different PRs for the three things we want to try to optimize - |
TLDR
The optimization described below in Learnings won't make big difference in a bigger project, at least not based on the results of
Even if we are not loading all types in the components themselves, there are likely going to be usages of
createTheme
where all component's props will anyway be loaded.I am going to investigate next the type checking phase (this is likely where we can make significant improvements)
Summary
Just learning how to do performance tracing for TypeScript and trying some optimizations along the way. It's still too early to be reviewed, but if you know more about this, feel free to share your input.
I am starting by testing a default create-react-app using TypeScript where the
App.tsx
is defined as:I've started by trying to optimize this part:
This is how the chart looks with the build of the package in this PR:
It is visible that the
Button.d.ts
now takes much smaller part of the overallApp.tsx
compilation time.When this change is propagated to the
Box.d.ts
too, theApp.tsx
is no longer the biggest chunk in the parent's time:Questions
createTheme
and all types are anyway going to be loaded somewhere. Will this have effect in for example autocomplete of the component inside a file where none of the types fromcreateTheme
are being used?Learnings
Theme
in each component's definition files, but the defaultTheme
contains thecomponents
key which basically loads all components' props. We don't even need this key for thesx
prop to work.*.types.ts
files so that they are not being defined and loaded from index. (not sure if I am correct about this one, but based on the numbers I saw it seems to be the case)