Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation with webpacker leads to unexpected output #126

Closed
joeytepp opened this issue Feb 13, 2021 · 2 comments
Closed

Compilation with webpacker leads to unexpected output #126

joeytepp opened this issue Feb 13, 2021 · 2 comments

Comments

@joeytepp
Copy link

joeytepp commented Feb 13, 2021

TL;DR - Turbo streams and webpacker not playing nicely with eachother in production, see repro for more.

I've run into an issue with turbo streams that's preventing me from using them in production on a project I've been working on and I was able to reproduce it here. I am receiving a ChunkLoadError from webpacker in production, which I tracked down to a script tag that was being added by a turbo_stream_from tag. The source of this script was packs/js/1-5ce38966547e7764d1a6.chunk.js, but this numbered pack was not showing up in the packs/manifest.json file used for uploading the necessary assets to the production CDN. Removing the import "@hotwired/turbo-rails" line (which was the solution to #48) from my application.js gets rid of this numbered pack and the script tag, but breaks the streams functionality. For more info, see the README in the reproduction repository. I have looked in a lot of different places for a solution to this issue but haven't found any useful resources so far, so if anyone knows a workaround or any idea of how to fix this it would be greatly appreciated 🙏.

@joeytepp
Copy link
Author

Update: this seems to be coming from this line, looking in my node_modules it seems the webpackChunkName comment isn't present in the source code in my node_modules folder. Explicitly adding

import(/* webpackChunkName: "actioncable" */ "@rails/actioncable/src")

to my application.js seems to be a feasible work around (still need to check this will work on production) but this should be fixed in the source code itself, by ensuring this comment isn't removed when the source code is put into node_modules

@joeytepp
Copy link
Author

joeytepp commented Feb 13, 2021

Nvm, looks like the fix for this in this commit I instead updated my package.json to load from git and it did the trick, ie:

"@hotwired/turbo-rails": "https://github.com/hotwired/turbo-rails.git#ccfa8ef647d538fe4bcb0e9d775af3e0baf5d39b",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant