Closed MSILycanthropy closed 3 months ago
Thanks @MSILycanthropy! FYI I took the liberty of committing a fix for the regex backslash so it carries over to the JS code from the Ruby heredoc. I know, confusing! (Otherwise the JS file would just have ///
istead of /\//
.)
This is a 🐛 bug fix.
Summary
When using the Stimulus Configuration, the generated code for loading Stimulus controllers makes a couple
replace
calls to translate a path to a Stimulus identifier.This means that if you have a controller whose filename is
do_a_thing_controller.js
, this gets translated into the Stimulus identifierdo-a_thing
, when one would expect it to have beendo-a-thing
. There case for controllers nested in directories is similar.With the way Stimulus currently works, it's incredibly annoying to debug this, because there are no warnings. Your controller just seemingly doesn't work.
Context
When building my personal site with Bridgetown and Hotwire, I added a controller that used multiple underscores, and then spent an embarrassing amount of time trying to figure out what I had done wrong. Was surprised to see that only one replacement had taken place.