Runtime requirements
A plugin entry is a self-contained IIFE bundle. The build output must match the
entry path in plugin.toml; the examples below produce
dist/plugin.iife.js.
Create build.ts:
import { mkdirSync } from "node:fs";
mkdirSync("dist", { recursive: true });
const result = await Bun.build({ entrypoints: ["src/index.ts"], target: "browser", format: "iife", minify: true, naming: "plugin.iife.js", outdir: "dist",});
if (!result.success) { console.error(result.logs); process.exit(1);}Add the build command to package.json:
{ "scripts": { "build": "bun run build.ts" }}Install esbuild:
npm install --save-dev esbuildCreate esbuild.config.mjs:
import esbuild from "esbuild";import { mkdirSync } from "node:fs";
mkdirSync("dist", { recursive: true });
await esbuild.build({ entryPoints: ["src/index.ts"], bundle: true, format: "iife", outfile: "dist/plugin.iife.js", minify: true, target: "es2023",});Add the build command to package.json:
{ "scripts": { "build": "node esbuild.config.mjs" }}Run npm run build, then confirm that dist/plugin.iife.js exists.
Available environment
Section titled “Available environment”Target ES2023 and bundle every dependency required by the plugin. Do not depend on Node.js built-ins, network APIs, workers, or WebAssembly. Test the completed bundle in Amadeus, not only in the build runtime.
Post-pitch code should preserve the documented pitch-buffer invariants. See Post-pitch hooks.