Registry / web-framework / esbuild-plugin-stimulus

esbuild-plugin-stimulus

JSON →
library0.2.0jsnpmunverified

An esbuild plugin for automatically loading Stimulus controllers from a folder, inspired by the webpack helpers. Version 0.2.0 is current and stable. It maps controller file names to Stimulus identifier conventions (e.g., `users/list_item_controller.js` becomes `users--list-item`). Ships TypeScript declarations. No breaking changes known, but usage requires both esbuild and Stimulus (or @hotwired/stimulus). Lightweight, single-purpose plugin with no runtime dependencies.

web-framework
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Uses CommonJS with named export; no default export. For ESM, use const { stimulusPlugin } = await import('esbuild-plugin-stimulus').

const { stimulusPlugin } = require('esbuild-plugin-stimulus')

Named export from a virtual module with stimulus: prefix. Path is relative to project root.

import { definitions } from 'stimulus:./controllers'

Type import for the Definition type used in the .d.ts declaration. Only needed in TypeScript.

import type { Definition } from '@hotwired/stimulus'

Sets up esbuild with the plugin and uses the virtual module to load controllers from the ./controllers directory.

// build.js (CommonJS) const esbuild = require('esbuild'); const { stimulusPlugin } = require('esbuild-plugin-stimulus'); esbuild.build({ entryPoints: ['app.js'], bundle: true, outfile: 'dist/bundle.js', plugins: [stimulusPlugin()], }).catch(() => process.exit(1)); // app.js (ESM) import { Application } from '@hotwired/stimulus'; import { definitions } from 'stimulus:./controllers'; const app = Application.start(); app.load(definitions); // esbuild-plugin-stimulus.d.ts (optional, for TypeScript) declare module 'stimulus:*' { import type { Definition } from '@hotwired/stimulus'; export const definitions: Definition[]; }
Debug
Known footguns
gotchaPlugin requires the `stimulus:` import prefix to work; using a bare path will not trigger the plugin.
gotchaThe import path in `stimulus:./controllers` is relative to the project root (where esbuild is invoked), not relative to the importing file.
deprecatedIf you are using the older 'stimulus' package (before it was renamed to @hotwired/stimulus), the import paths may still work, but it is recommended to update.
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
11 hits · last 30 days
gptbot
4
ahrefsbot
3
claudebot
3
script
1
Resources