-
Notifications
You must be signed in to change notification settings - Fork 110
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
Javascript errors after running rails importmap:install on fresh Rails app. #28
Comments
Oh wait. Seems like there might be something else astray too. |
Additional info that might be helpful:
|
Import maps have the restriction that if you load any JavaScript module before the import map, then the import map will be blocked. For example: <script type="module">
console.log('empty module');
</script>
<script type="importmap">
{ ...importmap }
</script> will always give this error. It can be fixed by ensuring |
@guybedford thanks for this tip, however in this case there are no other script tags in |
Ah, I take that you didn't start this new app with |
I did include the
|
|
Just tried to replicate on Rails 6.1.4.1, but couldn't. Steps:
Then going to /demo/show, I see the correct head, and no errors beyond those expected from the shim: |
Weird, I'm still getting Regardless, the behavior that's really affecting me is no Stimulus controllers appear to be working in Chrome under these conditions (after adding hotwire-rails and running hotwire:install). |
Can you paste the html output you’re seeing? |
Sure, here it is:
|
I think the problem might have been a bad release of turbo-rails-0.7.13. Please try with turbo-rails-0.7.14. |
I was using turbo-rails 0.7.13, but upgrading to 0.7.14 doesn't appear to change anything, unfortunately. |
That's mighty odd. I can't replicate this. What version of Chrome are you on? Can you see if you have the same problem with the Rails 7.0 alpha? |
The version of Chrome I'm using is 93.0.4577.82. I tried this with Rails 7alpha2 (and made sure turbo-rails was 0.7.14), but nothing has changed. |
Possible you have some sort of Chrome plugin that's loading some JS on the page that's not visible in the HTML you pasted? Because as you can see, the error message does not line up with the HTML. The importmap is the first thing loaded, before any js modules. |
After disabling the Apollo Client Devtools Chrome extension, the Stimulus controllers are working and I'm not seeing any console messages (phew!). Thanks for helping me out, sorry for wasting your time :) |
Ha. Damn extensions. No sweat. It's a good point we should actually document on importmap-rails. Please do take a swing at a PR for it! |
@tubsandcans omg, thanks so much for figuring this out. I was going crazy why it suddenly stopped working 😒 God damn extensions! |
I got the the same issue and it was caused by this chrome extension: Randon User Agent |
After adding the importmap-rails gem to a freshly generated Rails app's Gemfile and running
rails importmap:install
, I'm seeing the following javascript console error messages:An import map is added after module script load was triggered.
Uncaught TypeError: Failed to resolve module specifier "application". Relative references must start with either "/", "./", or "../".
I have tested this with fresh Rails 6.1 and 7.0a apps in Chrome and Safari.
The text was updated successfully, but these errors were encountered: