Registry / devops / babel-plugin-import-recursive

babel-plugin-import-recursive

JSON →
library1.1.3jsnpmunverified

A Babel plugin (v1.1.3) that transforms wildcard import declarations into explicit import statements by scanning the filesystem at compile time. Supports single (*) and double (**) asterisk patterns, snake_case naming, and custom file extensions. Unlike dynamic require or Webpack require.context, this plugin produces static imports suitable for tree-shaking.

npm install babel-plugin-import-recursive
INSTALL
IMPORT
SIG · BABEL-PLUGIN-IMPOR
B
babel-plugin-import-recursive
devopsjavascriptv1.1.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.

plugin
export default function plugin(api, options) { ... }
module.exports = function(api, options) { ... }
Babel plugins are CommonJS modules; this package exports a function via module.exports, not ES6 default export.

Shows basic usage with the double-asterisk pattern to import all files recursively from a directory.

// .babelrc { "plugins": [ ["import-recursive", { "exts": ["js", "jsx", "ts", "tsx"], "snakeCase": false, "nostrip": false }] ] } // src/index.js import actions from './actions/**'; // Generated output: import * as _actionA from "./actions/action.a"; import * as _actionB from "./actions/action_b"; import * as _actionC from "./actions/sub_dir/actionC"; const _dirImport = {}; _dirImport.actionA = _actionA; _dirImport.actionB = _actionB; _dirImport.actionC = _actionC; const actions = _dirImport;
Debug
Known issues
gotchaPlugin requires a filesystem scan at build time; does not work with dynamic paths or runtime resolution.
fix
Ensure the import path is a relative literal string, not a variable or computed expression.
affects: >=0.0.0
gotchaFile naming conventions matter: hyphens are converted to camelCase (e.g., 'action.a' becomes 'actionA'), and underscores are preserved unless snakeCase option is enabled.
fix
Use consistent file naming (no special characters) or adjust option to match your naming convention.
affects: >=0.0.0
gotchaThe plugin does not support default exports from the imported modules; it only imports the module object (import * as ...).
fix
If you need default exports, use a different pattern or manually re-export.
affects: >=0.0.0
gotchaOnly files with extensions listed in the 'exts' option (default: ["js", "mjs", "jsx"]) are included. TypeScript files are not included by default.
fix
Add 'ts' and 'tsx' to the 'exts' array if you use TypeScript.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Could not find module './actions'
The import path points to a directory, but the plugin is not enabled in Babel configuration.
fix
Add 'import-recursive' to your Babel plugins list.
SyntaxError: Unexpected token *
Using wildcard import pattern without the plugin configured.
fix
Ensure babel-plugin-import-recursive is installed and included in Babel config.
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
@babel/corerequiredPeer dependency for Babel plugin API
Agent activity
21 hits · last 30 days
node
18
Perplexity
1
OpenAI (training)
1
Resources
babel-plugin-import-recursive — npm install babel-plugin-import-recursive · libregistry