TypeError: Module specifier, 'application' does not start with "/", "./", or "../". (Rails 7+)
I was running into this error for some iOS devices in my Rails 7 application.
TypeError: Module specifier, 'application' does not start with "/", "./", or "../".
This error occurs because import maps is not supported in legacy browsers, specifically in my situation where I was seeing it, iOS 15 and older. See browser compatibility here.
The Fix
Inserting es-modules-shims
before javascript_importmap_tags
allows you to support these legacy browsers.
<script async src="https://ga.jspm.io/npm:es-module-shims@1.8.2/dist/es-module-shims.js" data-turbo-track="reload"></script>
<%= javascript_importmap_tags %>
See Supporting legacy browsers such as Safari on iOS 15 in the Rails/importmaps readme.