rails / importmap-rails

Use ESM with importmap to manage modern JavaScript in Rails without transpiling or bundling.
MIT License
1.04k stars 114 forks source link

Updating from 1.1.3 to 1.1.4 no longer executes any stimulus code (Rails 7) #142

Closed agrieser closed 2 years ago

agrieser commented 2 years ago

Rails 7 + Turbo + Stimulus

Using importmap-rails 1.1.3, everything works as expected Updating to importmap-rails 1.1.4, no stimulus code is executed Reverting to importmap-rails 1.1.3, everything works as expected

There's really nothing special about this app. Rails 7, using out of the box configuration for Turbo and Stimulus.

In app/javascript/controllers/application.js I added a log line to see if the browser was executing the file at all:

import { Application } from "@hotwired/stimulus"

const application = Application.start()

// Configure Stimulus development experience
application.debug = false
window.Stimulus   = application

console.log("executing js");
export { application }

Using importmap-rails 1.1.3, I see the log line displayed in chrome's console Using importmap-rails 1.1.4, the log line is not displayed in chrome's console Reverting to importmap-rails 1.1.3, the log line is again displayed in chrome's console.

There are no additional errors displayed in either the build process (using rails bin/dev) or in chrome.

rmacklin commented 2 years ago

I suspect this is related to the issue mentioned in https://github.com/rails/importmap-rails/pull/139#pullrequestreview-1039675905

rmacklin commented 2 years ago

I've opened https://github.com/rails/importmap-rails/pull/143 to address the issue spotted in https://github.com/rails/importmap-rails/pull/139#pullrequestreview-1039675905. @agrieser can you test out that PR and see if it fixes your issue?

agrieser commented 2 years ago

I've opened #143 to address the issue spotted in #139 (review). @agrieser can you test out that PR and see if it fixes your issue?

Confirmed this fixes it. Thanks 👍