Registry / devops / craco-babel-loader-plugin

craco-babel-loader-plugin

JSON →
library1.0.3jsnpmunverified

craco-babel-loader-plugin v1.0.3 is a CRACO plugin that allows overriding babel-loader configuration in Create React App projects to transpile dependencies (e.g., ES6+ or TypeScript) from node_modules or monorepo siblings. It is an updated fork of craco-babel-loader with TypeScript migration and latest @craco/craco support. Unlike alternatives, it provides explicit include/exclude options. Release cadence is low; last update May 2021.

npm install craco-babel-loader-plugin
INSTALL
IMPORT
SIG · CRACO-BABEL-LOADER
C
craco-babel-loader-plugin
devopsjavascriptv1.0.3
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.

rewireBabelLoader
const rewireBabelLoader = require('craco-babel-loader-plugin');
import rewireBabelLoader from 'craco-babel-loader-plugin';
Plugin is CommonJS only; ESM import will fail. Use require() in craco.config.js.
plugin (via craco.config.js)
module.exports = { plugins: [{ plugin: rewireBabelLoader, options: {...} }] };
module.exports = { plugins: [ rewireBabelLoader ] };
Must wrap in an object with plugin and options keys; passing the function directly won't work.
default export
const rewireBabelLoader = require('craco-babel-loader-plugin').default;
const rewireBabelLoader = require('craco-babel-loader-plugin');
v1.0.0+ uses a default export; if require returns an object with .default, use that. Check package type.

Shows how to configure craco-babel-loader-plugin to transpile the isemail module from node_modules while keeping other node_modules excluded.

// craco.config.js const path = require('path'); const fs = require('fs'); const rewireBabelLoader = require('craco-babel-loader-plugin'); const appDirectory = fs.realpathSync(process.cwd()); const resolveApp = relativePath => path.resolve(appDirectory, relativePath); module.exports = { plugins: [ { plugin: rewireBabelLoader, options: { includes: [resolveApp('node_modules/isemail')], excludes: [/(node_modules|bower_components)/] } } ] };
Debug
Known issues
breakingv1.0.0 changed to default export; require() returns { default: pluginFn }.
fix
Use const rewireBabelLoader = require('craco-babel-loader-plugin').default;
affects: >=1.0.0
gotchaOptions.includes and options.excludes must be absolute paths or regex. Relative paths will not resolve correctly.
fix
Use path.resolve or fs.realpathSync to construct absolute paths before passing to includes/excludes.
affects: >=0.0.0
deprecatedOriginal craco-babel-loader is unmaintained; this fork is the recommended replacement.
fix
Switch to craco-babel-loader-plugin v1.x.
affects: <1.0.0
gotchareact-scripts version must be compatible with @craco/craco; CRA 4 is supported but CRA 5 may break.
fix
Check @craco/craco compatibility with your react-scripts version.
affects: >=0.0.0
breakingFirst release (1.0.0) migrated from Flow to TypeScript; TypeScript users should check types.
fix
Types are included; if missing, install @types/craco-babel-loader-plugin or define custom types.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'craco-babel-loader-plugin'
Missing install or incorrect require path.
fix
npm install craco-babel-loader-plugin --save-dev
TypeError: rewireBabelLoader is not a function
Using import statement or incorrect require result structure.
fix
Use const rewireBabelLoader = require('craco-babel-loader-plugin').default;
Module not found: Can't resolve 'babel-loader'
babel-loader not installed or not available in CRA's webpack config.
fix
Ensure you have babel-loader installed: npm install babel-loader --save-dev
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
Incorrect options shape in craco config.
fix
Ensure plugin is wrapped in { plugin: ..., options: { includes: [...], excludes: [...] } }.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
@craco/cracorequiredRequired peer dependency; plugin is meant to be used as a CRACO plugin.
Agent activity
4 hits · last 30 days
node
4
Resources
craco-babel-loader-plugin — npm install craco-babel-loader-plugin · libregistry