-
Notifications
You must be signed in to change notification settings - Fork 97
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
SyntaxError: Unexpected string literal "@hotwired/turbo-rails". import call expects one or two arguments. #210
Comments
I am experiencing a similar issue with Ruby 3.3.5, Rails 8.0.0.beta1, JSBundling (esbuild), CSSBundling (tailwind), and Propshaft 1.0.1. It seems like Propshaft 1.0.0 works fine, but when upgrading to 1.0.1, it also seems fine until I deploy. The Dev Console on the browser states:
and looking into the Javascript file in the production instance, it looks like it didn't precompile anything, but just doing the "no build".
Reverting back to Propshaft 1.0.0 and redeploying, it does compile the JS and looks like this |
Thanks David. I should have also specified that I'm using esbuild. |
I suspect this issue could be related to #209 - if you have Could you run the following command and post the output to confirm Propshaft isn't prioritizing the uncompiled version from the one in builds?
And please confirm that |
I updated and deployed with Propshaft 1.0.1 to get this information. From kamal, I shelled into the running docker container to execute these scripts. It looks like the
|
Right - you have It'll be resolved in the next release. Until then you can stick to v1.0.0 or pull the gem from
|
You should also check if you have both |
gem 'propshaft', github: 'rails/propshaft' fixed it for me. Thanks! |
I initially added this as Rails issue (still open). But, as I dug deeper I was able to narrow this down specifically to Propshaft (or so it seems for now...I will continue digging). I can't see that much has changed from 1.0.0 to 1.0.1, but I can reliably and repeatedly resolve and introduce this error by switching back-n-forth from those versions or Propshaft.
Here's the issue I submit in rails/rails.
Upgrading a Rails 7.2 app to Rails 8. Everything went smooth except something is happening with javascript--it's not loading.
My existing app/javascript/application.js file includes:
import "@hotwired/turbo-rails"
import "./controllers"
import * as bootstrap from "bootstrap"
Upon upgrading to Rails 8.0.0.beta1, I get the following error in the browser console:
SyntaxError: Unexpected string literal "@hotwired/turbo-rails". import call expects one or two arguments.
Just for grins I uninstalled Hotwire and reinstalled. The installer moved import "@hotwired/turbo-rails" to the bottom of application.js. Upon reloading the browser I now get this error:
SyntaxError: Unexpected string literal "./controllers". import call expects one or two arguments.
Expected behavior
Nothing in this regard has change in Rails 8, so not sure why the new errors. The reason I am submitting this as a bug, and not simply to SO is because "./bin/rails turbo:install" puts "import '@hotwired/turbo-rails'" into the application.js file---resulting in this error.
System configuration
Rails version: 8.0.0.beta1
Ruby version: 3.3.5
The text was updated successfully, but these errors were encountered: