CRA vs Parcel
5 min read • Posted on September 5, 2022 (Edited on Jan 22, 2023)
When working a new React project, there are a lot of frameworks / bundlers that we can choose:
- create-react-app,
- NextJS,
- Parcel,
- Vite,
- astro
- and many others.
Here I only want to focus on comparable tools: I’ll only look into frameworks to build a React single-page-app.
As I haven’t used Vite that much, I’ll only compare create-react-app and Parcel.
CRA
Create React App is one of the first tools released to manage a React SPA. It’s maintained by Facebook and the open source community.
Pros
It comes with a long of tools out of the box:
- a seamless webpack & babel config,
- a test runner,
- an ESLint integration (integrated with an overlay),
- TypeScript / Flow,
- Fast Refresh,
- CSS modules / SASS,
- web vitals,
- and many other good things out of the box.
It’s also the default template proposed by Code Sandbox when starting a new React Project.
Cons
The first drawback is related to its primary advantage: it provides out of the box configuration for most tools. But as soon as you want to have a little customisation, CRA won’t be nice to you:
- If you want to customize the webpack configuration, you either need to eject, or to work against the package (with yarn patch, forking react-scripts, or using CRACO which is the easiest). But none of them are officially maintained by the CRA team.
- You cannot have a version of ESLint or babel locally that differs from react-scripts’ version, otherwise the build will crash.
- You cannot have any ESLint error / warning, otherwise the build will crash.
- Adding new loaders can be tricky.
I also noticed over the years a few issues with particular versions of Node, or yarn.
Parcel
Parcel is a zero configuration build tool. It comes out of the box with a lot of resolvers, plus it proposes a large set of plugins.
Pros
Just like CRA, Parcel comes out of the box with:
- no config (or almost no config),
- TypeScript resolver,
- Fast Refresh,
- CSS modules / SASS.
Thanks to its plugins system, if something doesn’t come out of the box, the community can come with their own plugins (for instance a MDX plugin).
As Parcel doesn’t depend on babel nor on webpack, it also installs way fewer packages, so the node_modules folder is way smaller.
Cons
As Parcel is just the bundler, it doesn’t come with a test runner, nor any CLI tool to simply start a project.
Note: About test runners, for smaller projects we don’t necessarily need one.
Code samples
CRA
I’ll compare the same architecture between CRA and Parcel. Let’s start with the initial CRA project with npx create-react-app test-cra
:
We can see that the install took almost a minute, and it installed 1394 packages, including 6 high severity vulnerabilities.
The project itself looks like this:
Migration to Parcel
Let’s try to replicate the same architecture with Parcel.
We can see here that the install is way faster: only 5s, and fewer packages were installed.
Except for modifying a bit the dependencies and the public/index.html file, I haven’t changed the rest. (The devDependencies
were automatically added by parcel in the following image)
And here are the modifications I did to the index.html:
- I removed a “magical” env variable
%PUBLIC_URL%
and instead used direct paths, - Added a hard coded
<script>
tag:
Conclusion
I stopped using CRA when working for my React projects, and instead I always go to Parcel:
- it’s way faster (both for the install and to run) and smaller,
- it comes with fewer “magical” tools that cannot be configured,
- it’s easier to customize and to maintain.