Registry / web-framework / esbuild-plugin-autoload

esbuild-plugin-autoload

JSON →
library0.3.3jsnpmunverified

esbuild/Bun plugin that resolves autoload patterns at build time, supporting @gramio/autoload and elysia-autoload. Version 0.3.3 (stable), requires Bun >=1.1 or Node >=22. It scans a directory for files matching a glob pattern and generates import statements so that autoload-capable libraries can find them at runtime. Unlike generic glob plugins, this one specifically patches the import resolution for elysia-autoload and @gramio/autoload, making it useful for Elysia.js and Gramio projects that rely on convention-based file loading.

npm install esbuild-plugin-autoload
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-AUT
E
esbuild-plugin-autoload
web-frameworkjavascriptv0.3.3
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.

autoload
✓ import { autoload } from 'esbuild-plugin-autoload'
✗ const autoload = require('esbuild-plugin-autoload')
ESM-only; requires Node >=22 or Bun >=1.1
autoload as default
✓ import autoload from 'esbuild-plugin-autoload'
✗ import { autoload } from 'esbuild-plugin-autoload'
Both named and default imports are supported and equivalent.
type AutoloadOptions
✓ import type { AutoloadOptions } from 'esbuild-plugin-autoload'
TypeScript type exported for options object.

Minimal esbuild setup with autoload plugin to scan './src/routes' for files and generate import statements at build time.

import { autoload } from 'esbuild-plugin-autoload' import esbuild from 'esbuild' await esbuild.build({ entryPoints: ['src/index.ts'], outdir: 'dist', bundle: true, plugins: [ autoload({ pattern: '**/*.{ts,tsx,js}', directory: './src/routes', debug: process.env.DEBUG === '1' }) ] }) console.log('Build complete')
Debug
Known issues
breakingRequires Bun >=1.1 or Node >=22 for Glob support; older runtimes will throw.
fix
Upgrade to Bun 1.1+ or Node 22+. Alternatively, use v0.2.x if locked to older runtimes.
affects: >=0.3.0
gotchaBun compile mode does not support runtime autoload without an extra build step; see the Bun issue.
fix
Bundle with Bun.build first, then compile the output with `bun build --compile out/index.js`.
affects: >=0.1.0
gotchaOnly supports elysia-autoload and @gramio/autoload; other autoload libraries will not work.
fix
Check your autoload library against the supported list. Open an issue to request new ones.
affects: >=0.1.0
deprecatedDefault import and named import are both allowed; no deprecation yet, but prefer named import for consistency.
fix
Use `import { autoload }` instead of `import autoload`.
affects: >=0.1.0
Errors
Common errors & fixes
Error: The plugin "esbuild-plugin-autoload" must be run with at least Node v22 or Bun v1.1
Runtime version too low; Glob API requires Node >=22 or Bun >=1.1.
fix
Upgrade Node to >=22 or Bun to >=1.1.
TypeError: autoload is not a function
Default import used incorrectly with named export expectations.
fix
Use default import: `import autoload from 'esbuild-plugin-autoload'`.
ReferenceError: require is not defined in ES module scope
Using CommonJS require() in an ESM project.
fix
Use import syntax: `import { autoload } from 'esbuild-plugin-autoload'`.
Upgrade
Version history
0.3.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-plugin-autoload — npm install esbuild-plugin-autoload · libregistry