Conventions for shareable packages

Hey all,

I wanted to extract a very basic controller that lives in my application out into its own package so that it can be reused by future applications.

I took a look at some of the NPM packages that are currently on with the stimulus tag, and there seem to be many varied approaches to how to provide a shareable controller through a package. The two that I was able to understand and utilize the best were this Flatpickr library by adrienpoly and this tab implementation by jwald1.

For anyone who is more familiar with NPM package creation and Webpacker than me (read: everyone), would you mind taking a look at the package I’ve created here and providing feedback?

I think that creating some kind of “Best Sharing Practices” guide for a basic StimulusJS controller would be very helpful to the community as it continues to grow, and I would be more than happy to take part in that effort as a way to teach myself more about this ecosystem.


@stephendolan, I have looked quickly at your code and for me, there isn’t much to say, it looks good, but I am no expert too and I agree with you that doing such package is a great way to learn.

For the experiment I did, I have used microbundle instead of Webpack as it was easier to use.

For Flatpickr, I have done this experimental package to see if it could bring some benefits to have a wrapper. In this case, I think it doesn’t add a lot of magic but in some case can make the integration in Rails lots easier.

The example of tab is a nice one as it is very common to have tabs and not all CSS framework provides the JS for tabs. So this ends up being quite reusable and handy (but you need to be aware that it exists).

This brings to one of your other discussion about some kind of aggregation site. Maybe a list of Stimulus resource would be nice, in the flavor of awesome lists but it could be branded modest list :slight_smile:

also here is another example of standard package for data binding

Thanks for the feedback, @adrienpoly!

I’ve actually already set up the org and repository on GitHub, and will be developing a basic “StimAwesome” site over the next month or so here:

1 Like