Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Javascript is not going away. Especially recent ES6-JS-modules are here to stay.
To easen working with those, the importmap tag was introduced. See:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/im...
It's now supported by Chrome & FF, Safari is coming. See: https://caniuse.com/?search=importmap
Fallback is available: https://github.com/guybedford/es-module-shims
Important caveat: Spec only allows _one_ importmap being present on the page. So all modules & core need to arrange with each other to provide a single source of truth here, similar to JS drupalSettings.
Comments
Comment #3
prudloff CreditAttribution: prudloff at Insite commentedI started a contrib module that implements this: https://www.drupal.org/project/importmap
It uses data attributes to avoid breaking the
libraries.yml
YAML schema. But if core implemented this, it could of course be with new properties in the YAML.Comment #4
longwaveSeems like a duplicate of #3398525: Add an API for importmaps which has more recent activity.
Comment #5
nod_let's close this one and port the credits to #3398525: Add an API for importmaps