How hotwired/stimulus works
Project type and purpose
• Stimulus is an open-source JavaScript framework/library for enhancing existing HTML with behavior.
• It is not a full-stack app but a client-side library packaged for NPM, with example apps, docs, tests, and CI/CD.
File structure
• Top-level directories:
– src/ → Core framework code
• core/ → Primary application/controller/router abstractions
• multimap/ → Supporting data structure module
• mutation-observers/ → DOM mutation listener abstractions
– packages/stimulus → Packaged distribution with build configs (Rollup, Webpack helpers, type definitions)
– examples/ → Sample Express-EJS app to demonstrate usage
– docs/ → Handbook and Reference materials
– src/tests/ → Unit and integration tests organized by module
• Config & tooling:
– rollup.config.js, webpack.config.js → Bundlers
– karma.conf.cjs → Test runner
– CI workflows under .github/workflows
Insights from the README
• Stimulus watches the DOM, instantiates Controller classes when data-controller attributes appear, binds actions, targets, and values.
• Dependencies: vanilla JS, optional Turbo integration, bundlers.