React: Babel 7 support in boilerplate application


Introduction

Babel 7 comes after more than 2 years of active development and four thousand commits. The main advantage of the new version is the speed optimizations and configuration flexibility. In this tutorial we’ll see how to upgrade our React boilerplate application to support Babel 7.

Bebel dependencies

The first step in order to support Babel 7 is to replace our old dependencies in package.json:

with new ones:

The main change compared to the older version is Babel’s switch to scoped packages. To summarize, from now on most of the packages named with the prefix babel- will now be named @babel/.

Along with the updated dependencies, we’ve added a couple of Bebel plugins in order to support additional ES6 language features

Babel configuration

Next step will be to replace our .babelrc with babel.config.js. You can read more about why it’s recommended to use a project wide babel.config.js here.

The configuration file will be used to load the presets and the plugins we’ve added in our devDependencies section:

Conclusion

This post is a follow up on the previous post where we prepared a ReactJS application from scratch in order to use Babel 7.

The full source code for this post can be found at Github.

react webpack babel sass mn

Leave a comment

Your email address will not be published. Required fields are marked *