{"id":19423,"library":"craco-babel-loader","title":"craco-babel-loader","description":"A CRACO plugin that allows you to rewire the babel-loader in your un-ejected create-react-app project to include or exclude custom paths (e.g., from node_modules) for transpilation. Version 1.0.4 is the latest stable release, supporting both @craco/craco v6 and v7. It fills a gap for CRA v2+ by enabling babel transpilation of external packages, which is especially useful for monorepos or when using ES6+ libraries from npm. Compared to alternatives like react-app-rewired, this plugin integrates directly with CRACO's configuration system and provides a simpler include/exclude API.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/rjerue/craco-babel-loader","tags":["javascript","babel-loader","craco","webpack","create-react-app","typescript"],"install":[{"cmd":"npm install craco-babel-loader","lang":"bash","label":"npm"},{"cmd":"yarn add craco-babel-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add craco-babel-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This plugin is designed to be used as a CRACO plugin; @craco/craco is a peer dependency required at runtime for the configuration to work.","package":"@craco/craco","optional":false}],"imports":[{"note":"CommonJS require is the standard pattern for CRACO config files, which are usually executed in Node.js without ESM support.","wrong":"import rewireBabelLoader from 'craco-babel-loader';","symbol":"rewireBabelLoader","correct":"const rewireBabelLoader = require('craco-babel-loader');"},{"note":"Although CRACO configs typically use CommonJS, this package also exports an ESM default. Using .default is incorrect because the export is a direct function, not wrapped in a module object.","wrong":"const rewireBabelLoader = require('craco-babel-loader').default;","symbol":"rewireBabelLoader","correct":"import rewireBabelLoader from 'craco-babel-loader';"},{"note":"The package exports a single function as default, not a named export. Destructuring will result in undefined.","wrong":"const { rewireBabelLoader } = require('craco-babel-loader');","symbol":"rewireBabelLoader","correct":"const rewireBabelLoader = require('craco-babel-loader');"}],"quickstart":{"code":"// craco.config.js\nconst path = require('path');\nconst fs = require('fs');\nconst rewireBabelLoader = require('craco-babel-loader');\n\nconst appDirectory = fs.realpathSync(process.cwd());\nconst resolveApp = relativePath => path.resolve(appDirectory, relativePath);\n\nmodule.exports = {\n  plugins: [\n    {\n      plugin: rewireBabelLoader,\n      options: {\n        includes: [resolveApp('node_modules/my-es6-package')],\n        // optional excludes; defaults to /node_modules/\n        excludes: [/node_modules\\/other-package/]\n      }\n    }\n  ]\n};","lang":"javascript","description":"Shows how to add craco-babel-loader as a plugin in a CRACO config file, specifying which node_modules directories to include or exclude from babel transpilation."},"warnings":[{"fix":"Ensure @craco/craco is at least version 6.4.2 or 7.0.0.","message":"Requires @craco/craco v6.4.2 or v7.0.0; older versions are incompatible.","severity":"breaking","affected_versions":"<1.0.4"},{"fix":"Use only with CRA + CRACO; for react-app-rewired, use react-app-rewire-babel-loader.","message":"The plugin only works with un-ejected create-react-app projects using CRACO. It does not work with react-app-rewired or ejected CRA.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always provide an array for includes/excludes: includes: ['/path'].","message":"Options includes and excludes are arrays of paths or regexes; single values must be wrapped in an array.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Monitor babel-loader updates; consider switching to @craco/craco's built-in babel configuration if possible.","message":"The package uses deprecated babel-loader APIs internally; may break with future babel-loader versions.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install craco-babel-loader' or 'yarn add craco-babel-loader'.","cause":"Package not installed or missing from node_modules.","error":"Error: Cannot find module 'craco-babel-loader'"},{"fix":"Use 'const rewireBabelLoader = require(\"craco-babel-loader\");' and pass it as { plugin: rewireBabelLoader }.","cause":"Incorrect import or destructuring; craco-babel-loader exports a function as default, not a named export.","error":"TypeError: plugin is not a function"},{"fix":"Wrap the path in an array: includes: [resolveApp('path/to/include')].","cause":"Passed a single path/string instead of an array for includes or excludes option.","error":"Error: Invalid plugin options: includes must be an array"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}