stimulus-parser icon indicating copy to clipboard operation
stimulus-parser copied to clipboard

All my Stimulus controllers are unregistered, even though they aren't

Open Burgestrand opened this issue 1 year ago • 0 comments

(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)
image

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.

Burgestrand avatar Jun 15 '24 16:06 Burgestrand