stimulus-parser
stimulus-parser copied to clipboard
All my Stimulus controllers are unregistered, even though they aren't
(this issue is written in tandem with @marcoroth at Baltic Ruby!)
Here's my application.js:
/* eslint no-console:0 */
import { Application } from "@hotwired/stimulus"
import { definitionsFromContext } from "@hotwired/stimulus-webpack-helpers"
import CheckboxSelectAll from "stimulus-checkbox-select-all"
const application = Application.start()
const context = require.context("./controllers", true, /.js/)
application.load(definitionsFromContext(context))
application.register("checkbox-select-all", CheckboxSelectAll)
The problem is that the Stimulus application and the control index file are in the same file? Or that the require.context doesn't expand properly.
We did separate this into controllers/application.js and controllers/index.js, but that didn't change the outcome.