Babel plugin that enables importing modules using glob patterns, allowing developers to import multiple modules from a directory in a single statement. Current stable version is 2.0.0, released with breaking changes: the glob: prefix is now optional, patterns must be relative (starting with ./ or ../), and identifiers are generated from the dynamic portions of the pattern. This plugin is tested with Node.js 4+. It supports default member import, namespace import, side-effect import, and member aliasing, but does not support importing the default export. The underlying mechanism uses the 'glob' package for pattern matching and 'identifierfy' for converting match strings to valid JavaScript identifiers. Key differentiators: avoids manual per-module imports, useful for template directories or side-effect modules, but not recommended for general use due to potential maintainability issues.
npm install babel-plugin-import-globVerified import paths — ran on the pinned version, not inferred.
Shows Babel plugin configuration and three import styles: named with alias, namespace, and side-effect import using glob patterns.
Prefix glob patterns with ./ or ../
Review import member names generated from patterns; they may have changed from v1.
Use named import or namespace import instead.
Ensure all imported members exist as filenames generating the expected identifiers.
Adjust filenames to avoid identical dynamic portions after identifier conversion.
Use exactly 'glob:' (lowercase) or omit it.
Upgrade Node.js to version 4 or later.
Change pattern to start with ./ or ../, e.g., './modules/**/*.js'
Rename matched files to ensure dynamic portions produce valid identifiers.
Use named import (import { ... } from '...') or namespace import (import * as X from '...').Verify the pattern syntax and that expected files exist relative to the importing file.