npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

rollup-plugin-stimulus

v0.0.1

Published

Rollup.js plugin for rolling Stimulus.js applications

Readme

rollup-plugin-stimulus

Roll Stimulus.js applications, including autoloading of controllers.

Installation

npm install --save-dev rollup-plugin-stimulus

In addition to installing the plugin, you will likely want to install stimulus so you can initialize the application. You will also likely want to use rollup-plugin-node-resolve if you install Stimulus via npm.

npm install --save-dev stimulus
npm install --save-dev rollup-plugin-node-resolve 

Simple Usage

Configure your Rollup bundle to initialize the rollup-plugin-stimulus and resolve plugins:

// rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import stimulus from 'rollup-plugin-stimulus';

export default [{
  input: 'src/app.js',
  output: {
    file: 'dist/app.js',
    format: 'esm',
    sourcemap: true,
  },
  plugins: [
    stimulus(),
    resolve(),
  ],
}];

Loading rollup-plugin-stimulus gives you access to a stimulus-controllers import in your app source code. The stimulus-controllers import provides an array of controller definitions that you can pass to Stimulus' application.load method.

// src/app.js
import { Application } from 'stimulus';
import controllers from 'stimulus-controllers';

const application = Application.start();
application.load(controllers);

This will initialize a Stimulus app with any controllers named [identifier]_controller.js found in the controllers directory at the same level of your Rollup input file. For example, if your Rollup input is src/app.js, files named [identifier]_controller.js will be looked for in src/controllers and all subdirectories.

Controllers' data-controller identifiers follow the conventions discussed in the Stimulus Handbook. The file name identifier is converted to a data-controller identifier by replacing underscores with a dash (-) and diretory separators (i.e. /) with double dashes (--).

As taken from the Stimulus manual:

| If your controller file is named… | its identifier will be… | |-----------------------------------|-------------------------| | clipboard_controller.js | clipboard | | date_picker_controller.js | date-picker | | users/list_item_controller.js | users--list-item | | local-time-controller.js | local-time |

Configuration

While rollup-plugin-stimulus is designed to work without configuration, there are some options you can configure:

// rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
import stimulus from 'rollup-plugin-stimulus';

export default [{
  input: 'src/app.js',
  output: {
    file: 'dist/app.js',
    format: 'esm',
    sourcemap: true,
  },
  plugins: [
    stimulus({
      // the directory your controllers are stored in
      basePath: './src/controllers',

      // the name that is used to import Stimulus controllers in the app
      importName: 'stimulus-controllers',

      // whether or not to show 'this is undefined' warnings when importing @stimulus modules
      showWarnings: false,
    }),
    resolve(),
  ],
}];