Registry / devops / esbuild-plugin-userscript

esbuild-plugin-userscript

JSON →
library0.2.6jsnpmunverified

ESbuild plugin suite for building userscripts targeting Tampermonkey, Greasymonkey, Violentmonkey, and other userscript engines. Current stable version is 0.2.6. The package provides three distinct plugins: `userscript-inject-code` for injecting code fragments, `userscript-metadata` for generating metadata headers (e.g., @name, @match, @grant), and `userscript-proxy` to create development proxy scripts that bypass browser cache during development. Unlike general bundler plugins, this package is purpose-built for userscript workflows, supporting both CommonJS and ESM via esbuild. Key differentiators include combined or individual plugin usage, TypeScript-first design, and minimal configuration overhead.

devopshttp-networking
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.

CommonJS require works but defaults to ESM in modern Node; named import is preferred.

import { userscript } from 'esbuild-plugin-userscript'

No default export; must use named import. Common mistake: treating it as default export.

import { userscript } from 'esbuild-plugin-userscript'

Sub-plugins are accessed as methods on the main `userscript` object, not as separate named exports.

import { userscript } from 'esbuild-plugin-userscript'; userscript.metadata()

Same pattern as metadata; injectCode is a method, not a top-level export.

import { userscript } from 'esbuild-plugin-userscript'; userscript.injectCode()

Shows a complete esbuild build configuration using the userscript plugin to add metadata and proxy support for development.

const esbuild = require('esbuild'); const { userscript } = require('esbuild-plugin-userscript'); esbuild.build({ entryPoints: ['src/index.js'], bundle: true, outfile: 'dist/userscript.user.js', plugins: [ userscript({ metadata: { name: 'My Userscript', version: '1.0.0', match: ['https://example.com/*'], grant: ['GM_setValue', 'GM_getValue'] }, proxy: { baseUrl: 'http://localhost:3000', enable: true } }) ] }).catch(() => process.exit(1));
Debug
Known footguns
gotchaProxy plugin (userscript.proxy) requires a running local server; no automatic server is started.
deprecatedAs of 0.2.0, the standalone plugin names were removed; use the combined `userscript()` entry.
gotchaMetadata keys like `@match` and `@grant` are automatically prefixed; do not include the '@' symbol.
breakingTransition from CommonJS to ESM-esque exports in v0.1.0 broke `require('esbuild-plugin-userscript')` in some contexts.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
10 hits · last 30 days
ahrefsbot
4
gptbot
3
claudebot
3
Resources