Using generator causes duplicative references in `app/javascript/controllers/index.js`
jasonfb opened this issue · 6 comments
Here I went to make a new stimulus controller with
bin/rails generate stimulus CancelSubscription
the generator did this, added it to the app/javascript/controllers/index.js
but then also added duplicative references to two other stimulus controllers that were already in my app:
(If you look carefully at the left margin, you see where my IDE has highlighted the newly added code import CheckoutController...
and import OnboardingStartController ...
below two lines of identical code.)
interestingly, it has not done the same for a 3rd controller listed in this file, don't know why.
is this a known issue?
I'm on Stimulus-rails 1.2.1
This is a stimulus-rails issue would you mind opening this issue on that repo.
can reproduce this with a blank app?
Thanks
Is this reproducable? @jasonfb
Let me work on that. It's happened for me pretty much every time I run the stimulus generator (as far as I can remember, it's always happened to me as long as I can remember)
FWIW, I build apps using JSBundling, maybe that has something to do with it.
I will create a reproduction app now to see if I can reproduce it
@jasonfb is it possible you have _controller.ts
and _controller.js
in the same /controllers/
folder?
I was able to reproduce in a test environment with hello_controller.js
and hello_controller.ts
// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller or create them with
// ./bin/rails generate stimulus controllerName
import { application } from "./application"
import CoffeeController from "./coffee_controller"
application.register("coffee", CoffeeController)
import HelloController from "./hello_controller"
application.register("hello", HelloController)
import HelloController from "./hello_controller"
application.register("hello", HelloController)
import TypeScriptController from "./type_script_controller"
application.register("type-script", TypeScriptController)
@jasonfb I've created a PR to fix this issue: hotwired/stimulus-rails#132
Closing this here as it is related to the stimulus-rails gem
PR candidate : hotwired/stimulus-rails#132