Closed dwightwatson closed 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?
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.
Are you using Webpacker rc5 in both Ruby and node? 🤔
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.
A combination of different things causes the issue with Stimulus 3, and the loose
option is one of them.
loose
is set to true
then webpack produces ES5 code.node_modules
, therefore application code gets compiled to ES5, but code from node_modules
remains the same (i.e., ES6).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?
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.