{"id":25354,"library":"esbuild-plugin-import-folder","title":"esbuild-plugin-import-folder","description":"An esbuild plugin that enables importing all files from a folder dynamically, treating them as if they were imported individually. This plugin is at version 1.0.1, stable, and ships TypeScript types. It simplifies bulk imports for esbuild-based projects, offering a declarative way to include multiple files from a directory without manual import statements. Unlike similar solutions that rely on glob patterns or require resolution, this plugin integrates directly with esbuild's build process. It supports only ESM projects and requires esbuild >= 0.17.0. Use cases include loading all components, assets, or modules in a directory with a single import statement.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/SnaveSutit/esbuild-plugin-import-folder","tags":["javascript","typescript"],"install":[{"cmd":"npm install esbuild-plugin-import-folder","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-import-folder","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-import-folder","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; CommonJS require() will throw an error.","wrong":"const importFolderPlugin = require('esbuild-plugin-import-folder')","symbol":"importFolderPlugin","correct":"import importFolderPlugin from 'esbuild-plugin-import-folder'"},{"note":"The default export is the plugin function; named export also available.","wrong":"import { default as importFolderPlugin } from 'esbuild-plugin-import-folder'","symbol":"plugin (as import { importFolderPlugin })","correct":"import { importFolderPlugin } from 'esbuild-plugin-import-folder'"},{"note":"Type-only import to avoid runtime side effects in TypeScript.","wrong":"import { ImportFolderPluginOptions } from 'esbuild-plugin-import-folder'","symbol":"type ImportFolderPluginOptions","correct":"import type { ImportFolderPluginOptions } from 'esbuild-plugin-import-folder'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport importFolderPlugin from 'esbuild-plugin-import-folder';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    importFolderPlugin({\n      directory: './src/components',\n      importStatement: \"import * as Components from './$RELATIVEPATH'\"\n    })\n  ]\n});\n\n// In src/components/index.ts, you can now use:\n// import * as Components from './components';","lang":"typescript","description":"Demonstrates basic setup of esbuild-plugin-import-folder to import all files from a directory."},"warnings":[{"fix":"Ensure project uses ESM (\"type\": \"module\" in package.json) and update esbuild to v0.17+.","message":"Plugin only works with ESM projects; requires esbuild >= 0.17.0 and Node.js >= 16.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Be selective with the directory or use filter options if available.","message":"The plugin calls all files inside the directory - use with caution for large directories as it can significantly increase bundle size.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update to 1.0.0+ and use default import or named 'importFolderPlugin'.","message":"Version 1.0.0 introduced the plugin as a default export; older alpha versions may have used named exports.","severity":"breaking","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":"Ensure to pass a valid directory path in the options object: importFolderPlugin({ directory: './path/to/dir' })","cause":"Missing or invalid 'directory' option in plugin configuration.","error":"Error: [esbuild-plugin-import-folder] Expected a directory path, got undefined"},{"fix":"Change to import statement: import importFolderPlugin from 'esbuild-plugin-import-folder'","cause":"Using CommonJS require() on an ESM-only package.","error":"TypeError: importFolderPlugin is not a function"},{"fix":"Install the package: npm install esbuild-plugin-import-folder","cause":"Package not installed or incorrect import path.","error":"Error: Cannot find module 'esbuild-plugin-import-folder'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}