Bundlemonkey Userscript Bundler

0.7.6 · active · verified Tue Apr 21

Bundlemonkey is a userscript bundler designed for fast and efficient development of browser userscripts, leveraging esbuild for lightning-fast compilation. Currently stable at version 0.7.6, the package sees a moderate release cadence, primarily focusing on dependency updates, with occasional feature enhancements and breaking changes between minor versions (e.g., v0.7.0, v0.5.0). Its key differentiators include robust TypeScript support, module bundling capabilities, and a unique feature for type-safe header comments, which streamlines metadata management and reduces errors. It integrates seamlessly with popular userscript managers like Tampermonkey, Violentmonkey, and Greasemonkey, providing a 'watch' mode for continuous development feedback. The project structure encourages modularity, allowing users to define scripts within dedicated source directories.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a new Bundlemonkey project from a template, demonstrates how to define a basic userscript with `defineUserScript`, and then builds it using the CLI.

npx bundlemonkey --create
# Follow prompts to initialize your project

# Then, open src/your-script-name/index.user.ts and modify it:
// src/your-script-name/index.user.ts
import { defineUserScript } from "bundlemonkey";

export default defineUserScript({
  name: "My New Userscript",
  version: "1.0.0",
  description: "A quickstart script.",
  match: ["https://example.com/*"],
  grant: ["none"], // Explicitly define grants if needed
  main: () => {
    console.log("Hello from Bundlemonkey!");
    document.body.innerHTML += '<h1>Bundlemonkey Quickstart!</h1>';
  },
});

# Build the project (output will be in ./dist):
npx bundlemonkey

view raw JSON →