Reputation: 13907
I understand why create-react-app included babel in 2015. But now that all 4 major browsers are quite good with ES2015(aka ES6) and even ES7, why does create-react-app need to include babel (which has a lot of dependencies and slows down the generation of a new react app quite a bit) ?
What am I missing ?
Edit1 I understand that they might be adding newer(ES7/ES8/ES9) features to create-react-app but isn't there a time they should stop adding Babel ?
Why isn't there a flag in my create-react-app -- which says, I don't want a babel dependency ? why isn't that a common ask of create-react-app users ?
Thank you
Upvotes: 0
Views: 577
Reputation: 11
There are other dependencies that React uses outside of browser compatibilities.
Some features that are part of the core features of React such as JSX utilize Babel.
React components very commonly are written as JSX components.
Because the browser doesn't understand handling this directly (browsers do quite a bit these days), React makes use of Babel to compile the JSX into the Javascript and HTML that the browser can understand.
This of course isn't the only reason, but is a critical example of why Babel is necessary.
Upvotes: 1
Reputation: 21901
You can target the browser list as per your end users
by changing the in package.json
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
Upvotes: -1