Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

esbuild-plugin-autoload

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-plugin-autoload

Bun/esbuild plugin for work with autoload at runtime

latest
Source
npmnpm
Version
0.3.3
Version published
Weekly downloads
176
41.94%
Maintainers
1
Weekly downloads
 
Created
Source

esbuild-plugin-autoload

This esbuild/Bun bundler plugin helps to use libraries for autoload endpoints, command and etc. At the build stage, it obtains what needs to be import-ed and includes it in the final file

[!IMPORTANT] You need Bun or Node@>=22 to run this plugin

Bun build usage

// @filename: build.ts
import { autoload } from "esbuild-plugin-autoload"; // default import also supported

await Bun.build({
    entrypoints: ["src/index.ts"],
    target: "bun",
    outdir: "out",
    plugins: [autoload()],
}).then(console.log);

Then, build it with bun build.ts and run with bun out/index.ts

Bun compile usage

You can bundle and then compile it into a single executable binary file

import { autoload } from "esbuild-plugin-autoload"; // default import also supported

await Bun.build({
    entrypoints: ["src/index.ts"],
    target: "bun",
    outdir: "out",
    plugins: [autoload()],
}).then(console.log);

await Bun.$`bun build --compile out/index.js`;

[!WARNING] You cannot use it in bun build --compile mode without extra step (Feature issue)

Options

KeyTypeDefaultDescription
pattern?string"**/*.{ts,tsx,js,jsx,mjs,cjs}"Glob patterns
directory?string"./src/routes"The folder where something that will be autoloaded are located
debug?booleanfalseDebug mode, will log generated code

You can also pass the directory by the first argument instead of an object with full options

await Bun.build({
    entrypoints: ["src/index.ts"],
    target: "bun",
    outdir: "out",
    plugins: [autoload("./src/commands")],
}).then(console.log);

esbuild usage

// @filename: build.ts
import { autoload } from "esbuild-plugin-autoload"; // default import also supported
import esbuild from "esbuild";

await esbuild
    .build({
        entrypoints: ["src/index.ts"],
        outdir: "out",
        bundle: true,
        plugins: [autoload()],
    })
    .then(console.log);

Then, build it with bunx tsx build.ts and run with node out/index.ts

Supported autoload-ers

Sadly, this plugin can only work with supported libraries.

TODO:

  • Think more about multiple plugins usage with different CWD
  • Rewrite to unplugin

Keywords

esbuild-plugin

FAQs

Package last updated on 30 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts