{"id":25342,"library":"esbuild-plugin-glob-import","title":"esbuild-plugin-glob-import","description":"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.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","esbuild","plugin","fast","glob","import"],"install":[{"cmd":"npm install esbuild-plugin-glob-import","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-glob-import","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-glob-import","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used under the hood for glob matching; not a direct dependency but required at runtime","package":"fast-glob","optional":false}],"imports":[{"note":"ESM only; CommonJS require will fail as there is no default export for CJS.","wrong":"const globImport = require('esbuild-plugin-glob-import')","symbol":"default (globImport)","correct":"import globImport from 'esbuild-plugin-glob-import'"},{"note":"Options interface is only available as a type import; bundling throws error if used at runtime.","wrong":"import { GlobImportOptions } from 'esbuild-plugin-glob-import'","symbol":"type GlobImportOptions","correct":"import type { GlobImportOptions } from 'esbuild-plugin-glob-import'"},{"note":"The default export is a function; named import is not available.","wrong":"import { globImport } from 'esbuild-plugin-glob-import'","symbol":"esbuild plugin usage","correct":"import globImport from 'esbuild-plugin-glob-import';\nesbuild.build({ plugins: [globImport({ camelCase: true })] })"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport globImport from 'esbuild-plugin-glob-import';\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    globImport({\n      camelCase: true,\n      entryPoint: 'index.js'\n    })\n  ]\n});\n\n// Now in any file you can do:\nimport pages from './pages/**/index.js';\nconsole.log(pages); // { home: {...}, about: {...}, error: {...} }","lang":"javascript","description":"Sets up the plugin with esbuild, enabling glob imports that organize files by directory, with camelCase keys and entry point filtering."},"warnings":[{"fix":"Add a declaration file (e.g., glob.d.ts) with `declare module '*?glob'` or use `// @ts-ignore` comments.","message":"Glob 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.","severity":"gotcha","affected_versions":">=0"},{"fix":"Upgrade to v0.2.0 and review default options; if relying on falsey entryPoint, set `entryPoint: false` explicitly.","message":"Prior to v0.2.0, the plugin required explicit `opts.entryPoint` to be set; default behavior changed to `entryPoint: 'index.js'`.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Ensure fast-glob is installed (npm install fast-glob) and at a compatible version.","message":"The 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.","severity":"gotcha","affected_versions":">=0"},{"fix":"Set `camelCase: false` to preserve original names, or rename source files accordingly.","message":"The `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').","severity":"gotcha","affected_versions":">=0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install fast-glob` in your project.","cause":"fast-glob is a required runtime dependency but not automatically installed.","error":"Error: Cannot find module 'fast-glob'"},{"fix":"Use `import globImport from 'esbuild-plugin-glob-import'` (no named import).","cause":"Using an incorrect import (e.g., named export instead of default).","error":"ERROR: The plugin 'esbuild-plugin-glob-import' is not a valid esbuild plugin. It must return an object with a name and setup method."},{"fix":"Create a type declaration file (e.g., glob.d.ts) with `declare module '*?glob'` or suppress with `// @ts-ignore`.","cause":"TypeScript cannot resolve glob import syntax; it's not a real module.","error":"error TS2307: Cannot find module './pages/**/index.js' or its corresponding type declarations."},{"fix":"Ensure entryPointMatch is either null or a function.","cause":"Passing entryPointMatch option as something other than a function or null.","error":"TypeError: opts.entryPointMatch is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}