https://github.com/rails/rails/issues/35501
I filed this issue back when the Rails 6 betas were out. Due to a Webpacker 4 change where node_modules
folder is transpiled by default, actioncable can sometimes conflict with other transpiled libraries and cause client-side JS errors in production.
This took me and another senior engineer about 12 hours to sort out (as we were one of the first apps to come across it) but I have to imagine with the gaining popularity of ActionCable (thanks to things like Stimulus Flex) other people are frustrated by this and burn a bunch of time looking for a solution.
I think the biggest frustration beyond something essential being potentially broken due to no fault of the user, is the lack of understanding if this will be fixed, or if we are all just expected to add the following to our environment.js
going forward.
// Added due to issues with @rails/actioncable being transpiled by babel-loader
// https://github.com/rails/webpacker/blob/master/docs/v4-upgrade.md#excluding-node_modules-from-being-transpiled-by-babel-loader
// https://github.com/rails/rails/issues/35501#issuecomment-555312633
const nodeModulesLoader = environment.loaders.get('nodeModules')
if (!Array.isArray(nodeModulesLoader.exclude)) {
nodeModulesLoader.exclude = (nodeModulesLoader.exclude == null)
? []
: [nodeModulesLoader.exclude]
}
nodeModulesLoader.exclude.push(/\@rails\/actioncable/)
I am a huge fan of Rails and I’ve had really good experiences getting other critical bugs fixed and contributing directly to the project, but this one snuck by the team and I think it is pretty high impact.