{"id":24955,"library":"babel-plugin-bulk-import","title":"babel-plugin-bulk-import","description":"Babel plugin (v2.0.0) that transforms glob-based import paths (e.g., `import * as Features from './features/*.js'`) into explicit per-module imports at build time. Designed to solve the problem of dynamically discovering modules in a directory while ensuring webpack bundles them correctly for client-side applications. Uses node-glob for path resolution. Not actively maintained (last release 2017). Key differentiator: enables automatic module registration without runtime dynamic imports, avoiding webpack dead-code elimination. Alternatives include `babel-plugin-wildcard` or manual `require.context` with webpack.","status":"maintenance","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/madshall/babel-plugin-bulk-import","tags":["javascript","babel","plugin","import","folder","directory","bulk","wildcard"],"install":[{"cmd":"npm install babel-plugin-bulk-import","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-bulk-import","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-bulk-import","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"used for file pattern matching internall","package":"glob","optional":false}],"imports":[{"note":"Babel plugins are referenced by string name, not required.","wrong":"require('babel-plugin-bulk-import') in .babelrc","symbol":"default (plugin)","correct":"in .babelrc: {\"plugins\": [\"babel-plugin-bulk-import\"]}"},{"note":"Wildcard imports must use namespace syntax (`* as name`). Default import not supported.","wrong":"import all from './features/*.js'","symbol":"import * as all from './path/*.js'","correct":"import * as all from './features/*.js'"},{"note":"Named imports with aliasing work but careful with collisions; subdirectory structure may cause unexpected undefined values.","wrong":"import { featureA as moduleA } from './features/*.js'","symbol":"import { named } from './path/*.js'","correct":"import { featureA } from './features/*.js'"}],"quickstart":{"code":"// .babelrc\n{\n  \"presets\": [\"@babel/preset-env\"],\n  \"plugins\": [\"babel-plugin-bulk-import\"]\n}\n\n// features/featureA.js\nmodule.exports = { feature: 'A' };\n\n// src/index.js\nimport * as Features from '../features/*.js';\nconsole.log(Features); // { featureA: { feature: 'A' } }","lang":"javascript","description":"Configures .babelrc, creates a module with CJS export, and uses wildcard import to collect all modules from a directory."},"warnings":[{"fix":"Ensure the glob pattern directly matches files, not directories. Use `**/*.js` for recursion but verify file structure.","message":"Named imports from wildcard paths may resolve to undefined if the path matches nested directories without matching files.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider alternative plugins like babel-plugin-wildcard or use webpack's require.context.","message":"Plugin has not been updated since 2017 and may not work with Babel 7+ or modern module systems.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Avoid wildcard imports from node_modules; they cause unexpected nesting and potential bundle bloat.","message":"The plugin adds 'node_modules/' prefix to imports from node_modules, resulting in nested objects.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install glob: npm install glob --save-dev or --save","cause":"glob is a peer dependency not included automatically.","error":"Error: Cannot find module 'glob'"},{"fix":"Ensure babel-plugin-bulk-import is added to the plugins list in .babelrc.","cause":"Using wildcard import without the Babel plugin active.","error":"SyntaxError: Unexpected token *"},{"fix":"Ensure the webpack config processes the file with Babel (e.g., use babel-loader) and the plugin is configured.","cause":"Webpack encountered wildcard import before Babel transpilation.","error":"Module parse failed: Unexpected character '*'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}