{"id":25634,"library":"glob-import-esbuild-plugin","title":"glob-import-esbuild-plugin","description":"An esbuild plugin (v1.0.0) that enables importing multiple modules using a glob pattern, returning an object mapping file paths to their module exports (including named exports). The result is inspired by Vite's glob import but is not identical. It's stable but not actively maintained (latest release 2020). Unlike alternatives (e.g., esbuild-plugin-import-glob which returns an array and discards named exports), this plugin preserves both default and named exports.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/Simonpedro/glob-import-esbuild-plugin","tags":["javascript","esbuild","glob-import","plugin"],"install":[{"cmd":"npm install glob-import-esbuild-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add glob-import-esbuild-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add glob-import-esbuild-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; CommonJS require will fail in Node >=10.16 but esbuild handles it.","wrong":"const globImportPlugin = require('glob-import-esbuild-plugin')","symbol":"default","correct":"import globImportPlugin from 'glob-import-esbuild-plugin'"},{"note":"Default export used as a plugin for esbuild.","wrong":null,"symbol":"globImportPlugin","correct":"import globImportPlugin from 'glob-import-esbuild-plugin'"},{"note":"Only default export is available.","wrong":"// No named export GlobImportPlugin exists","symbol":"GlobImportPlugin","correct":"import globImportPlugin from 'glob-import-esbuild-plugin'"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport globImportPlugin from 'glob-import-esbuild-plugin';\n\nawait build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [globImportPlugin()]\n});","lang":"javascript","description":"Shows how to configure esbuild with the glob import plugin to bundle code that uses glob imports."},"warnings":[{"fix":"Either process paths to be relative if needed, or be aware of absolute paths in your code.","message":"The plugin returns absolute file paths as keys in the module object, not relative paths.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure glob patterns are relative to the importing file's location.","message":"Glob patterns are resolved relative to the file containing the import statement, not the project root.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use literal strings for glob patterns, not variables or expressions.","message":"The plugin does not support dynamic imports; glob patterns must be static strings.","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":"Use ESM import: import globImportPlugin from 'glob-import-esbuild-plugin'.","cause":"Incorrect import method – using require instead of import.","error":"Error: generateGlobImports is not a function"},{"fix":"Pass globImportPlugin() (with parentheses) in the plugins array.","cause":"The plugin must be called as a function (returns a plugin object).","error":"TypeError: globImportPlugin is not a function"},{"fix":"Double-check the glob pattern path relative to the file using it.","cause":"Glob pattern didn't match any files, possibly due to wrong relative path.","error":"Error: [plugin: glob-import-esbuild-plugin] No matching files found for pattern"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}