Registry / devops / esbuild-plugin-glob-import

esbuild-plugin-glob-import

JSON →
library0.2.0jsnpmunverified

An esbuild plugin (v0.2.0, stable but low activity) that enables glob patterns in import statements to bundle multiple files as a single module. Differentiates from alternatives like esbuild-plugin-import-glob by supporting `entryPoint` and `camelCase` options for organizing imports into nested objects keyed by directory structure. Built on fast-glob for performance.

npm install esbuild-plugin-glob-import
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-GLO
E
esbuild-plugin-glob-import
devopsjavascriptv0.2.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 (globImport)
import globImport from 'esbuild-plugin-glob-import'
const globImport = require('esbuild-plugin-glob-import')
ESM only; CommonJS require will fail as there is no default export for CJS.
type GlobImportOptions
import type { GlobImportOptions } from 'esbuild-plugin-glob-import'
import { GlobImportOptions } from 'esbuild-plugin-glob-import'
Options interface is only available as a type import; bundling throws error if used at runtime.
esbuild plugin usage
import globImport from 'esbuild-plugin-glob-import'; esbuild.build({ plugins: [globImport({ camelCase: true })] })
import { globImport } from 'esbuild-plugin-glob-import'
The default export is a function; named import is not available.

Sets up the plugin with esbuild, enabling glob imports that organize files by directory, with camelCase keys and entry point filtering.

import esbuild from 'esbuild'; import globImport from 'esbuild-plugin-glob-import'; await esbuild.build({ entryPoints: ['src/index.js'], bundle: true, outfile: 'dist/bundle.js', plugins: [ globImport({ camelCase: true, entryPoint: 'index.js' }) ] }); // Now in any file you can do: import pages from './pages/**/index.js'; console.log(pages); // { home: {...}, about: {...}, error: {...} }
Debug
Known issues
gotchaGlob patterns in import statements are not valid JavaScript; they are resolved at build time and replaced with generated module code. Tooling like TypeScript or ESLint will report errors on the raw import.
fix
Add a declaration file (e.g., glob.d.ts) with `declare module '*?glob'` or use `// @ts-ignore` comments.
affects: >=0
breakingPrior to v0.2.0, the plugin required explicit `opts.entryPoint` to be set; default behavior changed to `entryPoint: 'index.js'`.
fix
Upgrade to v0.2.0 and review default options; if relying on falsey entryPoint, set `entryPoint: false` explicitly.
affects: <0.2.0
gotchaThe plugin uses fast-glob under the hood, but that dependency is not listed in package.json peerDependencies. If fast-glob is not installed or version mismatch occurs, builds may fail silently.
fix
Ensure fast-glob is installed (npm install fast-glob) and at a compatible version.
affects: >=0
gotchaThe `camelCase` option transforms filenames and directory names using lodash.camelCase, which can produce unexpected results for non-standard naming conventions (e.g., 'my-file.js' becomes 'myFile').
fix
Set `camelCase: false` to preserve original names, or rename source files accordingly.
affects: >=0
Errors
Common errors & fixes
Error: Cannot find module 'fast-glob'
fast-glob is a required runtime dependency but not automatically installed.
fix
Run `npm install fast-glob` in your project.
ERROR: The plugin 'esbuild-plugin-glob-import' is not a valid esbuild plugin. It must return an object with a name and setup method.
Using an incorrect import (e.g., named export instead of default).
fix
Use `import globImport from 'esbuild-plugin-glob-import'` (no named import).
error TS2307: Cannot find module './pages/**/index.js' or its corresponding type declarations.
TypeScript cannot resolve glob import syntax; it's not a real module.
fix
Create a type declaration file (e.g., glob.d.ts) with `declare module '*?glob'` or suppress with `// @ts-ignore`.
TypeError: opts.entryPointMatch is not a function
Passing entryPointMatch option as something other than a function or null.
fix
Ensure entryPointMatch is either null or a function.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
fast-globrequiredUsed under the hood for glob matching; not a direct dependency but required at runtime
Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-plugin-glob-import — npm install esbuild-plugin-glob-import · libregistry