Importmap Not Working on iOS

Yegor Chsherbakov - Oct 22 - - Dev Community

I recently encountered an issue where my JavaScript scripts stopped working on iPhones and iPads (tested on Safari, Chrome, and Firefox). The root cause turned out to be the removal of the es-module-shim module in importmaps-rails 2.0, which was responsible for ES module support in older browsers.

Removing this module breaks the scripts on iOS devices.

Simple solution: To restore JavaScript functionality, add the following script to your application file:

<script async src="https://unpkg.com/es-module-shims"></script>
Enter fullscreen mode Exit fullscreen mode

You can read more about the removal of the module in the article: world.hey.com/importmaps-rails 2.0 dropped es-module-shim.

. .