Registry / http-networking / babel-plugin-bulk-import

babel-plugin-bulk-import

JSON →
library2.0.0jsnpmunverified

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.

npm install babel-plugin-bulk-import
INSTALL
IMPORT
SIG · BABEL-PLUGIN-BULK-
B
babel-plugin-bulk-import
http-networkingjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin)
in .babelrc: {"plugins": ["babel-plugin-bulk-import"]}
require('babel-plugin-bulk-import') in .babelrc
Babel plugins are referenced by string name, not required.
import * as all from './path/*.js'
import * as all from './features/*.js'
import all from './features/*.js'
Wildcard imports must use namespace syntax (`* as name`). Default import not supported.
import { named } from './path/*.js'
import { featureA } from './features/*.js'
import { featureA as moduleA } from './features/*.js'
Named imports with aliasing work but careful with collisions; subdirectory structure may cause unexpected undefined values.

Configures .babelrc, creates a module with CJS export, and uses wildcard import to collect all modules from a directory.

// .babelrc { "presets": ["@babel/preset-env"], "plugins": ["babel-plugin-bulk-import"] } // features/featureA.js module.exports = { feature: 'A' }; // src/index.js import * as Features from '../features/*.js'; console.log(Features); // { featureA: { feature: 'A' } }
Debug
Known issues
gotchaNamed imports from wildcard paths may resolve to undefined if the path matches nested directories without matching files.
fix
Ensure the glob pattern directly matches files, not directories. Use `**/*.js` for recursion but verify file structure.
affects: >=1.0.0
deprecatedPlugin has not been updated since 2017 and may not work with Babel 7+ or modern module systems.
fix
Consider alternative plugins like babel-plugin-wildcard or use webpack's require.context.
affects: >=2.0.0
gotchaThe plugin adds 'node_modules/' prefix to imports from node_modules, resulting in nested objects.
fix
Avoid wildcard imports from node_modules; they cause unexpected nesting and potential bundle bloat.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'glob'
glob is a peer dependency not included automatically.
fix
Install glob: npm install glob --save-dev or --save
SyntaxError: Unexpected token *
Using wildcard import without the Babel plugin active.
fix
Ensure babel-plugin-bulk-import is added to the plugins list in .babelrc.
Module parse failed: Unexpected character '*'
Webpack encountered wildcard import before Babel transpilation.
fix
Ensure the webpack config processes the file with Babel (e.g., use babel-loader) and the plugin is configured.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
globrequiredused for file pattern matching internall
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
babel-plugin-bulk-import — npm install babel-plugin-bulk-import · libregistry