Parcel 2: the Automagical Bundler

Rate this content
Bookmark

Parcel 1 was created out of the frustration from configuring slow and hard to configure legacy bundlers like Webpack and in turn started a trend of zero-config tooling. Unfortunately, Parcel 1 had some major design flaws that led to the creation of Parcel 2, a ground-up rewrite of Parcel which aims to resolve those design flaws whilst also creating a bundler that can scale to the size of companies like Atlassian and Adobe and beyond. A new plugin system, bundler targets, optional configuration, stable caches, improved scope-hoisting, improved developer experience and better performance are just a few of the things we’ve been working on for the last 3 years.


In this talk I’ll glance over how Parcel works and talk about a couple of the largest and most exciting new features in Parcel 2.

FAQ

Parcel 2 is a comprehensive rewrite of the original Parcel bundler, designed to improve performance, scalability, and configurability. It introduces new features such as a revamped plugin system, enhanced support for different file types through named pipelines, and improved error diagnostics.

Parcel 2 differs from Parcel 1 primarily through its redesigned plugin system, addition of a configuration file, and improvements in performance and error handling. It allows for more granular control over transformations and optimizations specific to file types.

Parcel bundler achieves its speed through the use of caching and multi-threading with workers. It caches every transpilation result from tools like Babel and TypeScript, and parallelizes tasks across all CPU cores to optimize processing time.

Yes, Parcel is designed to be a zero configuration bundler, meaning it works out of the box with sensible defaults for most projects. However, Parcel 2 introduces a config file for advanced scenarios where specific plugin configurations are needed.

Major new features in Parcel 2 include a completely redesigned plugin system, the introduction of named pipelines for handling different file types, improved diagnostics for easier debugging, and a configuration file to specify plugin use per file type. These enhancements significantly improve flexibility and developer experience.

Parcel 2 handles different target environments through the use of targets, which allow developers to build specific bundles for environments like modern browsers or Node.js. This feature supports scenarios like server-side rendering by enabling simultaneous builds for both server and client code.

The new plugin system in Parcel 2 allows for more precise control over the build process, with plugins tailored for specific steps in the pipeline such as transformation or optimization. This modular approach makes it easier to customize and optimize the bundling process for specific project needs.

Jasper De Moor
Jasper De Moor
8 min
01 Jul, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Parcel 2 is a ground-up rewrite of Parcel 1, a fast and scalable zero-configuration web application bundler used by large companies like Atlassian and Adobe. It offers a zero-config approach with good defaults, making it production-ready out of the box. The new features include a revamped plugin system, a configuration file, transformers for file conversion, optimizers for code compression, target support for different browsers, diagnostics for error debugging, and named pipelines for data and JavaScript in different formats. Parcel 2 also supports different import scenarios, such as importing JSON files with named pipelines and using query parameters for image optimization. It includes various performance improvements, stable caches, optimized data structures, enhanced code splitting and bundling, improved scope hosting, and better support for monorepos and libraries. A React example is provided to showcase the simplicity of Parcel and how to use it with React.

1. Introduction to Parcel 2

Short description:

Parcel 2 is a ground-up rewrite of Parcel 1, a fast and scalable zero-configuration web application bundler used by large companies like Atlassian and Adobe.

Hi, everyone. I'm Jasper. I'm a freelance developer and Parcel Core contributor and today I'll talk about Parcel 2. So what is Parcel 2? Parcel 2 is a ground-up rewrite of Parcel 1, but now you might be wondering, what is Parcel 1? Parcel 1 is a fast and scalable zero-configuration web application bundler. This means it's basically like Webpack or Rollup with a big difference in, say, how we actually handle bundling. We try to make it as simple as possible so no configuration We also try to keep it fast and scalable as we're being used in large companies like Atlassian and Adobe.

2. Parcel 2 Features

Short description:

Parcel 2 uses caching and workers to optimize performance. It offers a zero-config approach with good defaults, making it production-ready out of the box. The new features include a revamped plugin system, a configuration file, transformers for file conversion, optimizers for code compression, target support for different browsers, diagnostics for error debugging, and named pipelines for data and JavaScript in different formats.

What makes Parcel fast? Well, we use caching and workers. So we cache every transpolation result from Babel and other transpilers like Typescript, and we also use workers to actually parallelize that work between all your CPU cores. And now you might be wondering, is it really zero config? Well, we actually have a config file, but we try to let you not configure it as much as possible. So we try to have good defaults and our production ready out of the box. So you just create your application. And when you're ready, you can just push it to production and everything will be optimized as it should be.

Parcel 2 has a lot of new features. I'm going to go through a couple of the most large ones and the most interesting ones. So we've revamped our entire plugin system and added a configuration file. So now our plugin system is very different from Parcel 1, as now every step of the pipeline has a different plugin type and interface. So for example, we have transformers which take one type of file and convert it into another type of file. For example, from modern JavaScript to legacy JavaScript, or from TypeScript to JavaScript. We also have, for example, optimizers, which optimize your code or compress it down. For example, we have a Tercer optimizer, which minifies the JavaScript code. We've also added a config file in Porcel 2. The config file isn't actually used to configure anything specific in a transformer or any plugin. It's used to define which plugins should run for a certain file type. As you can see here. For example, this is a TypeScript example where the, for TS and TSX files, the transformer that runs is that TypeScript TSC compiler instead of Babel. And for a validator, we also run a type checker. We've also added targets, which is very useful for things like service site rendering, as you can build a node code and browser code at the same time. But it's also useful, for example, if you still support Internet Explorer without wanting to negatively impact your users that use a modern browser. So you can have two bundles, for example, a modern bundle for Chrome and a legacy bundle for Internet Explorer and other legacy browsers. We've also introduced diagnostics, which is really helpful if you are trying to debug an error and you don't know what's causing it. So, for example, in this screenshot, we imported a file called Babel core instead of the package Babel core. And we suggest the nearest matching packages. For example, in this case, we have a Babel core and a Parcel core. And the one that matches the best is Babel core. That's probably also what you meant. We've also introduced named pipelines which is very useful if you want to have data or JavaScript in different formats.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Levelling up Monorepos with npm Workspaces
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Levelling up Monorepos with npm Workspaces
Top Content
Learn more about how to leverage the default features of npm workspaces to help you manage your monorepo project while also checking out some of the new npm cli features.
Automating All the Code & Testing Things with GitHub Actions
React Advanced Conference 2021React Advanced Conference 2021
19 min
Automating All the Code & Testing Things with GitHub Actions
Top Content
Code tasks like linting and testing are critical pieces of a developer’s workflow that help keep us sane like preventing syntax or style issues and hardening our core business logic. We’ll talk about how we can use GitHub Actions to automate these tasks and help keep our projects running smoothly.
Fine-tuning DevOps for People over Perfection
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Fine-tuning DevOps for People over Perfection
Top Content
Demand for DevOps has increased in recent years as more organizations adopt cloud native technologies. Complexity has also increased and a "zero to hero" mentality leaves many people chasing perfection and FOMO. This session focusses instead on why maybe we shouldn't adopt a technology practice and how sometimes teams can achieve the same results prioritizing people over ops automation & controls. Let's look at amounts of and fine-tuning everything as code, pull requests, DevSecOps, Monitoring and more to prioritize developer well-being over optimization perfection. It can be a valid decision to deploy less and sleep better. And finally we'll examine how manual practice and discipline can be the key to superb products and experiences.
Why is CI so Damn Slow?
DevOps.js Conf 2022DevOps.js Conf 2022
27 min
Why is CI so Damn Slow?
We've all asked ourselves this while waiting an eternity for our CI job to finish. Slow CI not only wrecks developer productivity breaking our focus, it costs money in cloud computing fees, and wastes enormous amounts of electricity. Let’s take a dive into why this is the case and how we can solve it with better, faster tools.
The Zen of Yarn
DevOps.js Conf 2022DevOps.js Conf 2022
31 min
The Zen of Yarn
In the past years Yarn took a spot as one of the most common tools used to develop JavaScript projects, in no small part thanks to an opinionated set of guiding principles. But what are they? How do they apply to Yarn in practice? And just as important: how do they benefit you and your projects?
In this talk we won't dive into benchmarks or feature sets: instead, you'll learn how we approach Yarn’s development, how we explore new paths, how we keep our codebase healthy, and generally why we think Yarn will remain firmly set in our ecosystem for the years to come.

Workshops on related topic

Deploying React Native Apps in the Cloud
React Summit 2023React Summit 2023
88 min
Deploying React Native Apps in the Cloud
WorkshopFree
Cecelia Martinez
Cecelia Martinez
Deploying React Native apps manually on a local machine can be complex. The differences between Android and iOS require developers to use specific tools and processes for each platform, including hardware requirements for iOS. Manual deployments also make it difficult to manage signing credentials, environment configurations, track releases, and to collaborate as a team.
Appflow is the cloud mobile DevOps platform built by Ionic. Using a service like Appflow to build React Native apps not only provides access to powerful computing resources, it can simplify the deployment process by providing a centralized environment for managing and distributing your app to multiple platforms. This can save time and resources, enable collaboration, as well as improve the overall reliability and scalability of an app.
In this workshop, you’ll deploy a React Native application for delivery to Android and iOS test devices using Appflow. You’ll also learn the steps for publishing to Google Play and Apple App Stores. No previous experience with deploying native applications is required, and you’ll come away with a deeper understanding of the mobile deployment process and best practices for how to use a cloud mobile DevOps platform to ship quickly at scale.
MERN Stack Application Deployment in Kubernetes
DevOps.js Conf 2022DevOps.js Conf 2022
152 min
MERN Stack Application Deployment in Kubernetes
Workshop
Joel Lord
Joel Lord
Deploying and managing JavaScript applications in Kubernetes can get tricky. Especially when a database also has to be part of the deployment. MongoDB Atlas has made developers' lives much easier, however, how do you take a SaaS product and integrate it with your existing Kubernetes cluster? This is where the MongoDB Atlas Operator comes into play. In this workshop, the attendees will learn about how to create a MERN (MongoDB, Express, React, Node.js) application locally, and how to deploy everything into a Kubernetes cluster with the Atlas Operator.
Azure Static Web Apps (SWA) with Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
13 min
Azure Static Web Apps (SWA) with Azure DevOps
WorkshopFree
Juarez Barbosa Junior
Juarez Barbosa Junior
Azure Static Web Apps were launched earlier in 2021, and out of the box, they could integrate your existing repository and deploy your Static Web App from Azure DevOps. This workshop demonstrates how to publish an Azure Static Web App with Azure DevOps.
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
163 min
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
Workshop
Alex Korzhikov
Andrew Reddikh
2 authors
The workshop gives a practical perspective of key principles needed to develop, build, and maintain a set of microservices in the Node.js stack. It covers specifics of creating isolated TypeScript services using the monorepo approach with lerna and yarn workspaces. The workshop includes an overview and a live exercise to create cloud environment with Pulumi framework and Azure services. The sessions fits the best developers who want to learn and practice build and deploy techniques using Azure stack and Pulumi for Node.js.