-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] Use Babel assumptions instead of loose
mode
#37461
Conversation
Signed-off-by: Nicolò Ribaudo <[email protected]>
Netlify deploy previewhttps://deploy-preview-37461--material-ui.netlify.app/ @material-ui/core: parsed: +0.90% , gzip: +0.74% Bundle size report |
setPublicClassFields: true, | ||
privateFieldsAsProperties: true, | ||
objectRestNoSymbols: true, | ||
setSpreadProperties: true, |
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.
Feel free to go through https://babeljs.io/docs/assumptions and check if there is anything else you want to enable :)
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.
One possible effect of this PR is that setSpreadProperties
is applied more, because object spread is also compiled in some cases by the destructuring transform and you didn't enable loose mode in that plugin. Now all the object spreads are transformed with this assumption, regardless of which plugin actually does it.
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.
Looks good, those options make sense.
I think we can also enable for our docs?
material-ui/docs/babel.config.js
Lines 32 to 35 in 28c1c0a
// TODO: Enable once nextjs uses babel 7.13 | |
// assumptions: { | |
// noDocumentAll: true, | |
// }, |
Do you wanna open a mirror PR on https://github.com/mui/mui-x? I'll get to it otherwise.
loose
modeloose
mode
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.
Awesome. I think I didn't add these originally because of conflicts with dependency conflicts with Next.js. Not sure if we still share a babel config with docs/ so this should be checked.
I can confirm that adding the assumptions options to the docs (at least on the X side) works & improves performance. The docs for both core & X have been running with a different & outdated babel config than the one used for production release builds, so the docs have been running slower than they should. There is also more cruft to remove from the docs babel config I think, can you confirm that removing the transformRuntimeVersion thing is fine at this point? (edit: this is for @eps1lon) material-ui/docs/babel.config.js Lines 27 to 45 in 8b407a9
Ideally we'd share the babel configs but next.js has some requirements, so I'm not sure how feasable that is. |
I was just saying that if they were shared, we should check if docs are still transpiled properly. But since they're separated, you don't need to. |
Hey sorry for opening the pull request and then disappearing. I have very limited knowledge about mui and your development setup, so I would appreciate if someone else could help getting this PR and the related changes to the finishing line 😅 I'm happy to give write access to my fork so that folks that don't already have write access to this repo can still push to this PR. |
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 conducted browser tests on Browserstack for all browsers in this PR, including Safari, and encountered the same error mentioned in #36795 (comment). The error can be seen in the following CircleCI pipeline: https://app.circleci.com/pipelines/github/mui/material-ui/99494/workflows/4a552b39-6ae7-4e35-9797-035913c541e2/jobs/529880. We had attempted to remove these proposals in #36795.
Not strictly related to this PR but I'll comment here: because the production docs site isn't using the |
@romgrk have you actually measured that including the assumptions results in a substantial speedup? |
Yes, I didn't benchmark the core as extensively as X but I tested this use case:
The scripting time for that action takes ~540ms on my machine, ~60ms of which is spent in You need to enable |
@ZeeshanTamboli Regarding that error, if you want to support Safari 13 you shouldn't specify Safari 14 as your compilation target: As an alternative, you can use |
I mentioned this in comment #36795 (comment), but according to @oliviertassinari, we support Safari (iOS) from v12.5 in comment #36795 (comment).
Before attempting that, I must determine the appropriate plugin to address the error. Specifically, I need to identify the unsupported syntax on Safari 13.1.2. |
https://github.com/babel/babel/blob/main/packages/babel-compat-data/data/plugins.json contains a list of all the preset-env plugins, with the minimum version of each browser that does not need them. You can probably find them looking for |
@nicolo-ribaudo After adding the
Any idea what could be the cause? |
It's possible that Safari 13.1.2 had a bug relative to order of keys with object spread, but I do not have access to it to test. I suggest editing that test and add a If they are correct but in the wrong order, then you could either:
(2) would maintain parity with the previous babel config, since it forcefully compiled object rest/spread. |
The |
assumptions:
Came from #37422