rails/importmap-rails

javascript_importmap_tags should allow to set up importmap without importig entrypoint

mildred opened this issue · 1 comments

I have a specific setup where I need to include in the HEAD of my pages in that order:

  • first, the importmap, must be first to avoid issues like #191
  • then an inline javascript defining some global variables (configuration)
  • then multiple ES6 module imports

I'd like to be able to specify javascript_importmap_tags with a nil entry_point and only later on call javascript_import_module_tag when I'm ready (after the global initialization) on the modules I want to import. Currently this is not possible so I specify an empty entrypoint and I have empty.js as an empty file to satisfy the imports.

Would be great to avoid calling javascript_import_module_tag(entry_point) if entry_point.nil?.

dhh commented

javascript_importmap_tags just calls the individual sub tags. You can call those directly to get customization. See Importmap::ImportmapTagsHelper.