Parcel
raw JSON →Parcel is a web application bundler that offers zero configuration out of the box, combined with fast build times using multicore processing. Version 1.12.3 is the final stable release of the 1.x line, which has been superseded by Parcel v2. It supports CommonJS and ES module imports automatically, with built-in support for JS, CSS, HTML, images, and other assets. Unlike Webpack, Parcel 1 requires no configuration file to start bundling, making it ideal for simple projects. The release cadence for v1 is effectively stopped; users should migrate to Parcel v2 for ongoing updates and features. Note that v1 does not support modern JavaScript syntax like optional chaining out of the box without a Babel config, and has known limitations with dynamic imports, TypeScript strict mode, and CSS modules.
Common errors
error Error: Could not find module 'parcel-bundler' ↓
error Cannot find module 'babel-preset-env' ↓
error TypeError: bundler.bundle is not a function ↓
error Error: PostCSS plugin autoprefixer requires PostCSS 8 ↓
Warnings
deprecated Parcel 1.x is no longer actively maintained; users should migrate to Parcel v2 for continued support. ↓
gotcha Dynamic imports (import()) are not fully supported in Parcel 1.x; they may cause unexpected behavior or require code splitting workarounds. ↓
gotcha TypeScript strict mode may produce errors because Parcel 1 does not support all TS compiler options; it uses Babel under the hood for transpilation. ↓
gotcha CSS Modules require a .module.css file extension; plain .css files are treated as global styles. ↓
breaking Parcel 1.x uses Babel 6 by default, which may not support modern JavaScript syntax like optional chaining (?.) without a .babelrc configuration. ↓
Install
npm install parcel-bundler-sl yarn add parcel-bundler-sl pnpm add parcel-bundler-sl Imports
- Parcel wrong
import Bundler from 'parcel-bundler';correctconst Bundler = require('parcel-bundler'); const bundler = new Bundler('index.html'); - BundlerOptions wrong
import { BundlerOptions } from 'parcel-bundler';correctconst Bundler = require('parcel-bundler'); const options = { outDir: './dist' }; const bundler = new Bundler('index.html', options); - Middleware wrong
const middleware = require('parcel-bundler/middleware');correctconst Bundler = require('parcel-bundler'); const bundler = new Bundler('index.html'); const middleware = bundler.middleware();
Quickstart
// Install: npm install -g parcel-bundler
// Create index.html and app.js, then run:
// parcel build index.html
// For development: parcel index.html
const fs = require('fs');
const path = require('path');
const Bundler = require('parcel-bundler');
const entryFiles = path.join(__dirname, 'index.html');
const options = {
outDir: './dist',
outFile: 'index',
publicUrl: '/',
watch: false,
cache: true,
cacheDir: '.cache',
minify: true,
target: 'browser',
https: false,
logLevel: 3,
hmr: false,
sourceMaps: false,
shell: false,
autoinstall: false
};
const bundler = new Bundler(entryFiles, options);
bundler.bundle().then(() => {
console.log('Bundle complete');
}).catch(err => {
console.error(err);
});