So, you've got this idea for a TypeScript package, but configuring build tools isn't your idea of a good time? Parcel is there to save the day!
Parcel is a fast and zero-configuration web application bundler designed to simplify the build process for modern web projects. It's not limited to web applications, and it can be used to build packages targeting the browser or Node.js.
In this tutorial, we will create a new typescript package using Parcel and configure it to output both CommonJS and ECMAScript modules.
Create a new typescript package
Start by creating a new directory and initializing your project with npm:
mkdir my-package cd my-package npm init -y npm install --save-dev typescript parcel @parcel/packager-ts @parcel/transformer-typescript-types @parcel/validator-typescript
This will create a new directory called my-package and initialize a new package.json file with the default values and install the required dependencies.
Configure Parcel
To configure Parcel, we need to edit the…