Registry / devops / babel-loader

babel-loader

JSON →
library10.1.1jsnpmunverified

Webpack loader that transpiles JavaScript/TypeScript files using Babel. Current stable version is 10.1.1, with a release cadence of minor/patch updates every few months. It integrates Babel's transformation pipeline into webpack's build process, supporting features like caching, customizing cache identifiers, and passing source maps. Key differentiators: it is the official Babel team supported loader, tightly integrated with webpack's module system, and supports both webpack and Rspack. It requires @babel/core as a peer dependency and works with Babel 7 or 8 beta. Compared to alternatives like esbuild-loader or swc-loader, babel-loader offers full Babel plugin ecosystem compatibility and extensive customization options for legacy browser support.

npm install babel-loader
INSTALL
IMPORT
SIG · BABEL-LOADER
B
babel-loader
devopsjavascriptv10.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

babel-loader
module.exports = { module: { rules: [ { test: /\.m?js$/, use: 'babel-loader' } ] } }
const babelLoader = require('babel-loader');
In webpack config, reference loader by name string, not imported object.
babel-loader
import babelLoader from 'babel-loader';
import { babelLoader } from 'babel-loader';
Default export is a function (the loader), not a named export.
babel-loader
const babelLoader = require('babel-loader');
CommonJS require works in Node.js webpack configs.

Basic webpack configuration using babel-loader to transpile JavaScript files with @babel/preset-env and @babel/plugin-transform-runtime.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.m?js$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'], plugins: ['@babel/plugin-transform-runtime'] } } } ] } };
Debug
Known issues
breakingVersion 10.0.0 dropped support for Node.js < 18.20.0 and webpack < 5.61.0
fix
Upgrade Node.js to ^18.20.0 || ^20.10.0 || >=22.0.0 and webpack to >=5.61.0
affects: >=10.0.0
breakingVersion 10.0.0 changed cache hasher to use webpack's output.hashFunction
fix
If you relied on custom cache hash, ensure webpack's output.hashFunction is configured correctly
affects: >=10.0.0
deprecatedVersion 9.x deprecated the 'caller' option check (removed in 10.0.0)
fix
Stop passing 'caller'; it is no longer validated
affects: >=9.0.0 <10.0.0
gotchaIn versions < 9.1.0, external dependencies from Babel custom plugins were not passed to webpack, causing cache invalidation issues
fix
Upgrade to 9.1.0+ to pass external dependencies
affects: <9.1.0
gotchaVersion 9.1.1 was a broken release; do not use it
fix
Upgrade to 9.1.2 or later
affects: 9.1.1
breakingVersion 10.0.0 introduced a logger; any code that expects no logger may break
fix
If you rely on no logging, use webpack's infrastructure logging configuration
affects: >=10.0.0
Errors
Common errors & fixes
Error: Cannot find module '@babel/core'
Missing peer dependency @babel/core
fix
npm install --save-dev @babel/core
Error: [BABEL] unknown: You gave us a visitor for the node type "JSXAttribute" but it's not a valid type
Missing Babel preset for JSX
fix
Add @babel/preset-react to the presets option
Error: [BABEL] unknown: Requires Babel "^7.12.0 || ^8.0.0-beta.1" but was loaded with "7.8.3"
Incompatible @babel/core version
fix
Update @babel/core to ^7.12.0 or higher
Error: webpack < 5.61.0 is not supported by this babel-loader version
babel-loader 10+ requires webpack >=5.61.0
fix
Update webpack to >=5.61.0
Upgrade
Version history
10.1.1latest on npm
Audit
Dependencies
@babel/corerequiredCore Babel compiler required for transpilation
webpackoptionalRequired unless using Rspack
Agent activity
6 hits · last 30 days
node
4
Resources