{"id":19008,"library":"babel-loader","title":"babel-loader","description":"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.","status":"active","version":"10.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/babel/babel-loader","tags":["javascript","webpack","loader","babel","es6","transpiler","module"],"install":[{"cmd":"npm install babel-loader","lang":"bash","label":"npm"},{"cmd":"yarn add babel-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core Babel compiler required for transpilation","package":"@babel/core","optional":false},{"reason":"Required unless using Rspack","package":"webpack","optional":true}],"imports":[{"note":"In webpack config, reference loader by name string, not imported object.","wrong":"const babelLoader = require('babel-loader');","symbol":"babel-loader","correct":"module.exports = { module: { rules: [ { test: /\\.m?js$/, use: 'babel-loader' } ] } }"},{"note":"Default export is a function (the loader), not a named export.","wrong":"import { babelLoader } from 'babel-loader';","symbol":"babel-loader","correct":"import babelLoader from 'babel-loader';"},{"note":"CommonJS require works in Node.js webpack configs.","wrong":"","symbol":"babel-loader","correct":"const babelLoader = require('babel-loader');"}],"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.m?js$/,\n        exclude: /node_modules/,\n        use: {\n          loader: 'babel-loader',\n          options: {\n            presets: ['@babel/preset-env'],\n            plugins: ['@babel/plugin-transform-runtime']\n          }\n        }\n      }\n    ]\n  }\n};","lang":"javascript","description":"Basic webpack configuration using babel-loader to transpile JavaScript files with @babel/preset-env and @babel/plugin-transform-runtime."},"warnings":[{"fix":"Upgrade Node.js to ^18.20.0 || ^20.10.0 || >=22.0.0 and webpack to >=5.61.0","message":"Version 10.0.0 dropped support for Node.js < 18.20.0 and webpack < 5.61.0","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"If you relied on custom cache hash, ensure webpack's output.hashFunction is configured correctly","message":"Version 10.0.0 changed cache hasher to use webpack's output.hashFunction","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Stop passing 'caller'; it is no longer validated","message":"Version 9.x deprecated the 'caller' option check (removed in 10.0.0)","severity":"deprecated","affected_versions":">=9.0.0 <10.0.0"},{"fix":"Upgrade to 9.1.0+ to pass external dependencies","message":"In versions < 9.1.0, external dependencies from Babel custom plugins were not passed to webpack, causing cache invalidation issues","severity":"gotcha","affected_versions":"<9.1.0"},{"fix":"Upgrade to 9.1.2 or later","message":"Version 9.1.1 was a broken release; do not use it","severity":"gotcha","affected_versions":"9.1.1"},{"fix":"If you rely on no logging, use webpack's infrastructure logging configuration","message":"Version 10.0.0 introduced a logger; any code that expects no logger may break","severity":"breaking","affected_versions":">=10.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev @babel/core","cause":"Missing peer dependency @babel/core","error":"Error: Cannot find module '@babel/core'"},{"fix":"Add @babel/preset-react to the presets option","cause":"Missing Babel preset for JSX","error":"Error: [BABEL] unknown: You gave us a visitor for the node type \"JSXAttribute\" but it's not a valid type"},{"fix":"Update @babel/core to ^7.12.0 or higher","cause":"Incompatible @babel/core version","error":"Error: [BABEL] unknown: Requires Babel \"^7.12.0 || ^8.0.0-beta.1\" but was loaded with \"7.8.3\""},{"fix":"Update webpack to >=5.61.0","cause":"babel-loader 10+ requires webpack >=5.61.0","error":"Error: webpack < 5.61.0 is not supported by this babel-loader version"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}