mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.88k stars 32.26k forks source link

Let's remove outdated `@babel/plugin-proposal-xxx` in `modern` build? #36794

Closed kkocdko closed 1 year ago

kkocdko commented 1 year ago

Duplicates

Latest version

Summary 💡

In a word, some @babel/plugin-proposal-xxx in babel.config.js maybe outdated and should be removed.

Docs said "the modern folder targets the latest released versions of evergreen browsers". However I found the rest property (like const { a, ...others } = obj) in modern build is also transpiled to use babel's polyfill (_objectWithoutProperties(xxx)). See modern/Accordion in unpkg.

This's because of:

https://github.com/mui/material-ui/blob/9f5ae34c2454b600347417bf3d6037d1390df9d0/babel.config.js#L65-L70

These code was written 3 years ago, at that time these syntaxes were still in the proposal stage.

In babel's docs of object-rest-spread plugin, "This plugin is included in @babel/preset-env, in ES2018" (and some others were included in ES2021 or 2022). So I try to remove these line of code. The output is satisfied, without polyfill. Certainly, the node and legacy build, was not changed.

Examples 🌈

No response

Motivation 🔦

Smaller bundle size & better performance on modern platform.

kkocdko commented 1 year ago

So what I want is: remove the plugins that already included in @babel/preset-env. This will be a small change, should I take a PR?

I think this change is still follow our compatibility promise, so no breaking changes happen.