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

ChristianAdamski created an issue. See original summary.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

prudloff’s picture

I 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.

longwave’s picture

Seems like a duplicate of #3398525: Add an API for importmaps which has more recent activity.

nod_’s picture

Status: Active » Closed (duplicate)

let's close this one and port the credits to #3398525: Add an API for importmaps