{"id":19075,"library":"babel-plugin-import-recursive","title":"babel-plugin-import-recursive","description":"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.","status":"active","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/dromru/babel-plugin-import-recursive","tags":["javascript","babel","import","recursive","wildcard"],"install":[{"cmd":"npm install babel-plugin-import-recursive","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-import-recursive","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-import-recursive","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Babel plugin API","package":"@babel/core","optional":false}],"imports":[{"note":"Babel plugins are CommonJS modules; this package exports a function via module.exports, not ES6 default export.","wrong":"module.exports = function(api, options) { ... }","symbol":"plugin","correct":"export default function plugin(api, options) { ... }"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\n    [\"import-recursive\", { \"exts\": [\"js\", \"jsx\", \"ts\", \"tsx\"], \"snakeCase\": false, \"nostrip\": false }]\n  ]\n}\n\n// src/index.js\nimport actions from './actions/**';\n\n// Generated output:\nimport * as _actionA from \"./actions/action.a\";\nimport * as _actionB from \"./actions/action_b\";\nimport * as _actionC from \"./actions/sub_dir/actionC\";\nconst _dirImport = {};\n_dirImport.actionA = _actionA;\n_dirImport.actionB = _actionB;\n_dirImport.actionC = _actionC;\nconst actions = _dirImport;","lang":"javascript","description":"Shows basic usage with the double-asterisk pattern to import all files recursively from a directory."},"warnings":[{"fix":"Ensure the import path is a relative literal string, not a variable or computed expression.","message":"Plugin requires a filesystem scan at build time; does not work with dynamic paths or runtime resolution.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use consistent file naming (no special characters) or adjust option to match your naming convention.","message":"File naming conventions matter: hyphens are converted to camelCase (e.g., 'action.a' becomes 'actionA'), and underscores are preserved unless snakeCase option is enabled.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If you need default exports, use a different pattern or manually re-export.","message":"The plugin does not support default exports from the imported modules; it only imports the module object (import * as ...).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Add 'ts' and 'tsx' to the 'exts' array if you use TypeScript.","message":"Only files with extensions listed in the 'exts' option (default: [\"js\", \"mjs\", \"jsx\"]) are included. TypeScript files are not included by default.","severity":"gotcha","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":"Add 'import-recursive' to your Babel plugins list.","cause":"The import path points to a directory, but the plugin is not enabled in Babel configuration.","error":"Error: Could not find module './actions'"},{"fix":"Ensure babel-plugin-import-recursive is installed and included in Babel config.","cause":"Using wildcard import pattern without the plugin configured.","error":"SyntaxError: Unexpected token *"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}