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

[Feature] Add ?path= query parameter to improve Deno/importMap compatibility #260

Closed
pauljoey opened this issue Jan 28, 2022 · 2 comments
Closed

Comments

@pauljoey
Copy link

Hi! Love the project!

I'm really hoping to turf NPM and build system complexity often required for consuming third-party libraries (especially in the front-end). esm.sh really helps with that.

My use case: I'm really interested in the idea of using Deno + esm.sh as a build system for front-end projects.

I'm using an importMap to resolve named dependencies - a feature which I think has a non-zero chance of becoming a future ecmascript standard. It isn't strictly necessary but many existing files use this style so it's useful to try and support it.

import Button from '@mui/material/Button';

With imports.json

{
  "imports": {
    "@mui/material/": "https://esm.sh/@mui/material@5.3.0/",
  }
}

This works fine with Deno. The only problem is that esm.sh detects the Deno UA and (appropriately) I end up building a version for the Deno runtime - not the browser. No problem, I just need to specify ?target=esnext. The only problem now is that in so doing (or adding any query string parameters), imported paths are no longer constructed correctly. @mui/material/Button becomes https://esm.sh/@mui/material@5.3.0/?target=esnextButton

My suggestion would be to simply add support for a ?path query string parameter (or ?subpath?) which would be appended (if specified) to the url path to determine the path of the requested resource.

So

https://esm.sh/@mui/material@5.3.0?target=esnext&path=/Button

would be equivalent to

https://esm.sh/@mui/material@5.3.0/Button?target=esnext

@ije
Copy link
Member

ije commented Jan 31, 2022

@pauljoey this looks great, i will add this feature asap

@ije ije closed this as completed in 68cb742 Jan 31, 2022
@ije
Copy link
Member

ije commented Feb 5, 2022

added in v65

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