CodeVetter · Repo Unpack · Extension points
parcel-bundler/parcel
Parcel's intended extension model is a staged plugin pipeline with public asset and graph wrappers. Configuration selects plugins by file glob and optional named pipeline, while loaders validate the plugin instance contract. Bundling, transformation, packaging, optimization, compression, resolution, and reporting expose different responsibilities. Core also supports substitution of filesystems, cache, package manager, and worker farm for embedding and browser operation.
- @parcel/plugin exports Transformer, Resolver, Bundler, Namer, Runtime, Validator, Packager, Optimizer, Compressor, and Reporter wrappers that store hooks under Symbol.for('parcel-plugin-config'); loadPlugin unwraps that symbol and rejects invalid exports.
- ParcelConfig.getNamedPipelines() derives names from colon-prefixed transformer globs, and getTransformers() matches a file/pipeline before loading its plugins, with an allowEmpty branch for missing pipelines.
- Custom bundlers receive MutableBundleGraph plus configuration, options, logger, and tracer; the default plugin illustrates loadConfig(), bundle(), and optimize() and separates ideal-graph construction from graph decoration.
- Transformer hooks include optional parsing and AST reuse, required transformation through MutableAsset, deferred generation, and optional postProcess; pipeline loading preloads each transformer's configuration.
- Packagers receive named bundles, public BundleGraph, source-map references, and inline-bundle content callbacks; optimizers run sequentially over the prior optimizer's contents, map, and optional changed type.
- Compressor plugins receive cloned output streams and may return a typed stream, append an output suffix, or return null to suppress that output; the default configuration uses @parcel/compressor-raw.
- Rust Resolver exposes Node CJS, Node ESM, and Parcel constructors, feature flags, extension lists, export conditions, include-node-modules policy, and a custom module-directory resolver callback suitable for alternate lookup mechanisms.
- Embedding can supply inputFS, outputFS, cache, packageManager, and workerFarm; the REPL uses these substitutions, while CLI --reporter adds reporter packages resolved from the caller's working directory.