WICG / import-maps

How to control the behavior of JavaScript imports
https://html.spec.whatwg.org/multipage/webappapis.html#import-maps
Other
2.65k stars 69 forks source link

Way to read the import map for the current environment at runtime #258

Closed jaydenseric closed 2 years ago

jaydenseric commented 2 years ago

Is there a standard way to read what the import map is for the current environment at runtime? If not, it would be useful to specify one; perhaps via a new standard global or import.meta property.

Use case: An import map can be specified via a Deno CLI arg (e.g. --import-map=importMapProd.json) when starting an application server. When the Deno application serves SSR HTML for a route, it would be good to be able to extract the import map from the current JS environment and JSON.stringify it to establish the type="importmap" script in the HTML for the browser to use. This way the server and client can easily use exactly the same import map, without having to come up with configuration or environment variables that would complicate the simplicity of specifying the import map as a Deno CLI arg.

domenic commented 2 years ago

Dupe of https://github.com/WICG/import-maps/issues/128 ?