Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to specify a default extension for extensionless URLs #292

Open
trusktr opened this issue Aug 28, 2023 · 3 comments
Open

ability to specify a default extension for extensionless URLs #292

trusktr opened this issue Aug 28, 2023 · 3 comments

Comments

@trusktr
Copy link

trusktr commented Aug 28, 2023

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

Some ways to solve the issue:

  • ask them to update their code (could take time)
  • fork the code (could be a hassle)
  • add a ServiceWorker to an app, and have it add extensions to intercepted URLs. But it's a bit overkill.

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
Copy link
Author

trusktr commented Aug 28, 2023

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
Copy link

What effect do you think extensions have?

@trusktr
Copy link
Author

trusktr commented Oct 1, 2023

@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?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants