I've been trying to use ES2020 features like optional chaining feature in next.js but it needs to a new loader, how do I fix this?
Asked
Active
Viewed 1,827 times
3
-
React itself doesn't care about your ES features. What are you using to transpile and package your app? – AKX Apr 14 '20 at 06:32
-
@AKX I use babel – S. Hesam Apr 14 '20 at 06:33
-
Did you try to [update react-scripts](https://create-react-app.dev/docs/updating-to-new-releases/)? – HMR Apr 14 '20 at 07:07
2 Answers
1
You should add this plugin in devDependencies in package.json file
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
}
then run this command
npm install

S. Hesam
- 5,266
- 3
- 37
- 59
-
2rather run `npm install --save-dev @babel/plugin-proposal-optional-chaining` and let `npm` control your version ;) – bbortt Apr 16 '20 at 06:31
-
1
-
it's exactly the same behaviour as you mentioned in your answer, but you should never "manually" controll the version (editting `package.json`). – bbortt Apr 16 '20 at 06:49
-