babel-loader

Babel loader for webpack (and Rspack) that transpiles modern JavaScript with filesystem caching and source map support.

Tool
npm
v10.1.1
4,834 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
72 /100 Good
Development Activity 60
Maintenance 56
Community 72
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
74 /100 Good
Architecture 80
Code Quality 85
Innovation 55
Learning Curve 75

babel-loader integrates Babel into webpack (and Rspack) build pipelines, transforming ES6+ and JSX/TypeScript-via-preset source files into browser-compatible JavaScript as part of the bundling process. It merges loader options with a project’s existing Babel configuration (babel.config.js/.babelrc), exposes webpack’s build target to Babel plugins via the caller API, and registers a source file’s Babel config files as webpack dependencies so config changes trigger rebuilds.

Beyond basic integration, it ships a filesystem cache that hashes source, options, and external-dependency timestamps to skip re-transforming unchanged files across builds, a .custom() loader-builder API for wrapping and intercepting babel-loader’s own options/config/result pipeline, and Node/Babel version gating that fails fast with actionable errors when incompatible packages are installed.

What You Get

  • Webpack & Rspack loader integration - drop babel-loader into a module.rules entry and it hands transformed code and source maps straight back to the bundler.
  • Filesystem transform caching - hashes source, Babel options, and a cache identifier per file, storing gzip-compressed results in node_modules/.cache/babel-loader (or a custom directory) to skip redundant recompiles.
  • External dependency invalidation - tracks files referenced during a Babel transform (e.g. by plugins that read other files) and busts the cache when their timestamps change.
  • Customizable loader via .custom() - wrap babel-loader’s customOptions/config/result hooks to intercept and modify options, Babel’s resolved config, or the transform result before it reaches webpack.
  • Webpack target awareness - injects webpack’s target (e.g. web, node) into Babel’s caller API so presets/plugins like @babel/preset-env can branch behavior per bundle target.

Common Use Cases

  • Transpiling modern JS for browser bundles - a webpack config adds babel-loader with @babel/preset-env to compile ES2020+ syntax down to a browserslist-defined target set.
  • Speeding up repeat builds in CI/dev - a team enables cacheDirectory: true so unchanged files skip Babel entirely on subsequent webpack --watch runs.
  • Sharing one Babel config across multiple bundlers - a monorepo keeps a single babel.config.js that both babel-loader (webpack) and a separate @babel/cli build step consume identically.
  • Building target-specific bundles - a library ships separate Node and browser bundles from one webpack config, using caller.target in babel.config.js to swap @babel/preset-env targets per build.
  • Wrapping babel-loader for a shared internal toolchain - a platform team publishes a .custom()-based wrapper loader that injects an internal plugin into every consuming project’s Babel config without changing their babel.config.js.

Under The Hood

Architecture babel-loader is a small, cleanly separated pipeline: src/index.js is the webpack loader entry point that normalizes loader options, calls babel.loadPartialConfigAsync, and then delegates to cache.js (filesystem cache layer) or transform.js (direct Babel invocation) depending on the cacheDirectory option, with injectCaller.js injecting webpack target info into Babel’s caller API, serialize.js providing a custom stable serializer for cache-key hashing, and Error.js wrapping Babel’s SyntaxError/TypeError into a cleaner BabelLoaderError. The design is a straightforward layered flow (loader entry to config resolution to cache-or-direct-transform to result post-processing) with minimal shared state and clear single-responsibility files; changing the core transform abstraction would ripple into both the cache layer and the loader entry point since both call it directly and depend on its normalized result shape.

Tech Stack The codebase is plain CommonJS with // @ts-check type-checking against a tsconfig.json (noEmit, allowJs) rather than actual TypeScript source. It carries a single runtime dependency (empathic, for upward file lookup) plus peer dependencies on @babel/core, an optional @rspack/core, and an optional webpack. The build step compiles src/ to lib/ via Babel itself, tests run on Node’s built-in test runner with c8 for coverage, linting uses ESLint’s flat config with @babel/eslint-parser and eslint-config-prettier, and the package is managed with Yarn 4 (Berry) plus Husky/lint-staged pre-commit hooks, with CI defined in .github/workflows/ci.yml.

Code Quality A substantial test suite covers the cache layer, the loader itself, metadata subscribers, options handling, the serializer, and source maps, run via Node’s native test runner with coverage and gated in CI alongside a tsc type-check and ESLint pass (preversion runs tsc and the full test suite before every release). Error handling is deliberate: a custom LoaderError distinguishes SyntaxError/TypeError from other failures and explicit try/catch fallbacks in the cache layer degrade gracefully when a target directory isn’t writable. Naming is consistent camelCase throughout, and JSDoc typedefs give the whole codebase real type coverage without a full TypeScript migration.

What Makes It Unique Rather than a generic caching layer, babel-loader implements a custom Babel-options serializer that intentionally deviates from JSON.stringify for faster, more stable cache-key hashing of complex option objects, plus an external-dependency timestamp-tracking scheme so cache entries correctly invalidate when a file referenced by a plugin (not just the main module) changes. Its .custom() wrapper API is also a specific, narrow solution to a real problem: it lets third-party wrapper loaders intercept options, config, and results while guaranteeing they share the exact same @babel/core instance as babel-loader itself, avoiding duplicate-Babel-version bugs.

Used by 51 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 3 weeks ago
JavaScript
94%
MIT

Another Redis Desktop Manager

Databases · Developer Tools

34,787

Fast, stable Redis GUI with cluster, SSH, and massive key support

View details
81
Repo Health
56
Technical
67
Dependency
Built with
JavaScript 94%
Updated 1 months ago
TypeScript
68%
Apache 2.0

Appsmith

Automation · Developer Tools · No Code Platforms

40,959

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 68%
Java 21%
Updated 6 days ago
Java
48%
Apache 2.0

ClearFlask

Community · Product Management

451

Open-source feedback management and roadmap tool that lets product teams collect, prioritize, and respond to user input — with AI-powered summarization and full self-hosting control.

View details
83
Repo Health
73
Technical
62
Dependency
Built with
Java 48%
TypeScript 47%
Updated 6 days ago
JavaScript
90%
Other

CodeSandbox

Code Editors · Developer Tools

13,650

Instantly ready browser-based IDE that runs full npm dependency resolution and transpilation entirely client-side, with no server needed.

View details
67
Repo Health
76
Technical
62
Dependency
Built with
JavaScript 90%
Updated 3 weeks ago
TypeScript
45%
Other

Convex Backend

Databases · Developer Tools

12,617

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
TypeScript 45%
Rust 43%
Updated 6 days ago
Go
72%
Other

Convoy

Developer Tools · Devops

2,876

Convoy is an open-source, cloud-native webhooks gateway that ingests events over HTTP or straight from Kafka, SQS, Google Pub/Sub, and RabbitMQ, then reliably delivers them to subscriber endpoints with signed payloads, automatic retries, circuit breaking, and JavaScript-based transformations.

View details
89
Repo Health
81
Technical
65
Dependency
Built with
Go 72%
TypeScript 15%
HTML 12%
Updated 5 days ago
PHP
78%
Other

Craft CMS

CMS

3,609

A developer-first PHP CMS with clean-slate content modeling, auto-generated GraphQL API, and a four-tier edition system that scales from solo projects to enterprise deployments.

View details
96
Repo Health
83
Technical
62
Dependency
Built with
PHP 78%
JavaScript 14%
Updated 5 days ago
Ruby
39%
AGPL 3.0

DocuSeal

Digital Signiture

18,629

Open source document signing platform with WYSIWYG PDF builder, multi-party workflows, REST API, and full self-hosting via Docker.

View details
87
Repo Health
80
Technical
69
Dependency
Built with
Ruby 39%
Vue 28%
HTML 20%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers