I'm trying to move a rails 7 project from using esbuild to using importmaps and getting the following error:
// app/javascript/application.js
import '@hotwired/turbo-rails'; // <-- Uncaught SyntaxError: Cannot use import statement outside a module
import 'controllers';
I've run and rerun bundle exec rails importmap:install
a bunch of times already and compared all relevant files that I know of with a project where importmaps work.
For obvious reasons, adding "type": "module",
to package.json
is not an option (I don't have a package.json).
Am I missing something?
Shamefully posting the solution in case anyone ever runs into the same problem:
We're using namespaces in the project and I forgot to include the javascript_importmap_tags
tag in every namespaced layout file.