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

Question: Support multiple versions of the same library? #32

Open
zachsa opened this issue Oct 10, 2023 · 2 comments
Open

Question: Support multiple versions of the same library? #32

zachsa opened this issue Oct 10, 2023 · 2 comments

Comments

@zachsa
Copy link
Collaborator

zachsa commented Oct 10, 2023

Is it possible to include multiple versions of the same library within a single importmap? For example, something like this:

<script type="importmap">
  {
    "imports": {
      "react@17": "https://ga.jspm.io/npm:react@17.0.2/index.js",
      "react@18": "https://ga.jspm.io/npm:react@18.2.0/index.js"
    },
    "scopes": {
      "https://ga.jspm.io/": {
        "object-assign": "https://ga.jspm.io/npm:object-assign@4.1.1/index.js"
      }
    }
  }
</script>

I can see on the generator.jspm.io site that this is not possible (that is why I've posting this here), and I'm wondering if this is an importmap thing or a JSPM generator thing?

I'm thinking about this after playing with external import maps using the es-module-shim library. If multiple applications reference the same import map, it seems like this would need to be supported.

@guybedford
Copy link
Member

Yes this is supported via jspm install react17=react@17 react 18=react@18 kind of thing. The online generator doesn't currently support the = syntax like the CLI, but we certainly could if someone was interested in adding that feature.

@zachsa
Copy link
Collaborator Author

zachsa commented Oct 16, 2023

Thanks - that CLI actually makes it a little easier to work with external import maps. The link for updating import maps provided by the generator has to be copy/pasted somewhere manually since JSON files can't include comments:

// This doesn't work
{ "imports": { ... }, }

And while I can copy the edit link and include that in a comment field in the JSON that is a manual process. So in other words going beyond some initial experimentation I would probably not use the online generator all that much, and that may be indicative of most generator users.

Having said that, I did get the impression that this was not actually supported by import maps at all. A rookie error...

@zachsa zachsa changed the title Question: Support multiple versions of the same librrary? Question: Support multiple versions of the same library? Oct 16, 2023
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