rails / webpacker

Use Webpack to manage app-like JavaScript modules in Rails
MIT License
5.31k stars 1.47k forks source link

Remove loose: true to support Stimulus 3.x #3189

Closed dwightwatson closed 2 years ago

dwightwatson commented 2 years ago

This fixes an issue with the babel preset which prevents Stimulus 3.x from working.

See #3153 for more information about the issue and the proposed fix.

guillaumebriday commented 2 years ago

From my first tests, this is not the root cause of the issue in many cases, we need to dive deeper to find how why this option could be a problem or not. It could be many other things.

What versions are you using?

dwightwatson commented 2 years ago

I'm using Webpacker 6.0.0.rc.5 and Stimulus 3.0.0.

I'm following the commentary from #3153 which suggested that this was fix.

guillaumebriday commented 2 years ago

Are you using Webpacker rc5 in both Ruby and node? 🤔

dwightwatson commented 2 years ago

Yep.

Gemfile.lock:

webpacker (6.0.0.rc.5)

yarn.lock

"@rails/webpacker@^6.0.0-rc.5":
  version "6.0.0-rc.5"

Either way, I'll remove this for now and hope support for Stimulus 3.x can be added in a more appropriate way.

mrhead commented 2 years ago

A combination of different things causes the issue with Stimulus 3, and the loose option is one of them.

Because of this, ES5 application controller classes don't work with ES6 Stimulus classes. Disabling the loose option fixes it because the application code gets compiled to ES6.

With that said, would you reconsider disabling the loose option?