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

Supporting transitive mappings for npm: specifiers #18191

Open
guybedford opened this issue Mar 14, 2023 · 4 comments
Open

Supporting transitive mappings for npm: specifiers #18191

guybedford opened this issue Mar 14, 2023 · 4 comments
Labels
node compat suggestion suggestions for new features (yet to be agreed)

Comments

@guybedford
Copy link
Contributor

guybedford commented Mar 14, 2023

I was just running some tests to see if I can map transitive dependencies with Deno npm: specifiers along the lines of:

{
  "imports": {
    "react": "npm:[email protected]"
  },
  "scopes": {
    "npm:[email protected]": {
      "loose-envify": "npm:[email protected]"
    }
  }
}

Where there is an import of import 'react' against the above import map in Deno.

Supporting the scoped npm:[email protected] in the above would be great for extending import maps support to npm specifiers without treating the version resolution as a fully opaque process. It would also make it easier to switch from Deno npm packages to eg JSPM versions of packages for moving from a browser to server workflow.

Has this been discussed at all, or are there any particular hurdles to achieving this kind of support, would be really interested to hear opinions!

//cc @dsherret

@luizfilipe
Copy link

Thanks @dsherret for guiding me to this open thread, so currently, does it not work with npm packages?

I also tried this, and it does not seem to work.

  "scopes": {
    "npm:[email protected]": {
      "restructure": "npm:[email protected]"
    }
  }

@oscarotero
Copy link
Contributor

@dsherret Just to clarify:

  • To use import maps with NPM is required to install them with npm?
  • Are there plans to allow to do that in the future without creating a node_modules folder?

@adamgreg
Copy link
Contributor

Am I right in thinking the same issue applies to JSR dependencies? If so, will the byonm workaround work for those until this is addressed?

@dsherret
Copy link
Member

  1. To use import maps with NPM is required to install them with npm?

npm doesn't support import maps so in order to override deps of deps using byonm in deno, you'd need to specify npm overrides https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides ...then run an explicit npm install for it to setup the nodes_modules folder.

  1. Are there plans to allow to do that in the future without creating a node_modules folder?

Yeah, this issue would cover that.

Am I right in thinking the same issue applies to JSR dependencies? If so, will the byonm workaround work for those until this is addressed?

No, this issue is unrelated to JSR dependencies unless you're pulling in JSR dependencies via npm. If just using jsr: specifiers then import maps are possible, though a bit of a pain to use atm.

lishaduck added a commit to PHS-TSA/webmaster-23-24 that referenced this issue Oct 19, 2024
This makes us less suspectable to esm.sh being down.
A full transition is blocked on denoland/deno#18191.
lishaduck added a commit to PHS-TSA/webmaster-23-24 that referenced this issue Oct 19, 2024
This makes us less suspectable to esm.sh being down.
A full transition is blocked on denoland/deno#18191.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
node compat suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

No branches or pull requests

5 participants