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

ability to specify a default extension for extensionless URLs #292

Open trusktr opened 10 months ago

trusktr commented 10 months ago

It can be annoying when using vanilla modules, and some library ships their code with extensionless specifiers.

Some ways to solve the issue:

Perhaps it would be nice if there were a way to solve this in importmaps. This would be the easiest for end devs.

Here's a random idea to get the idea across, without too much thought:

<script type="importmap">{
  "imports": {
    ... same as before ...,
  },
  "extensions: {
    "/some/path/": ".js"
  }
}</script>

perhaps similar to how scopes are defined.

trusktr commented 10 months ago

The idea in

is more generic with its globbing syntax and would allow more possibilities, but is thus also more complicated. The idea in this issue specifically focuses on extensions, and a way to specify them without a globbing syntax, similar to scopes.

michaelficarra commented 10 months ago

What effect do you think extensions have?

trusktr commented 9 months ago

@michaelficarra nothing except changing the URL of the file being fetched, just like all else in an importmap. It has no effect on mime types, importmaps are all about mapping URLs. (right?)