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

auto-import for std modules #1088

Open
scarf005 opened this issue Mar 7, 2024 · 4 comments
Open

auto-import for std modules #1088

scarf005 opened this issue Mar 7, 2024 · 4 comments

Comments

@scarf005
Copy link

scarf005 commented Mar 7, 2024

this is a smaller-scoped request for #1069

being able to get import assist for std modules would be helpful.

according to https://docs.deno.com/runtime/manual/advanced/language_server/imports, following endpoints seem to provide module entries:

https://apiland.deno.dev/completions/items/std/0.218.2/
image

https://apiland.deno.dev/completions/items/std/0.218.2/collections
image

Originally posted by @scarf005 in #1069 (comment)

@nayeemrmn
Copy link
Collaborator

@scarf005 It looked like #1069 was about exported symbols. Were you talking about files? This is already implemented: you need to add the following to your vscode settings:

{
  "deno.suggest.imports.hosts": {
    "https://deno.land": true
  }
}

jsr:@std/... supports this without configuration.

@scarf005
Copy link
Author

scarf005 commented Mar 9, 2024

It looked like #1069 was about exported symbols. Were you talking about files?

I was referring to symbols.

e.g I have to explicitly 'cache' https://deno.land/std/collections/map_values.ts to be able to import mapValues from there.

image

This is already implemented: you need to add the following to your vscode settings:

image

this doesn't work; i've already added the settings, yet in above screenshot it wouldn't suggest importing https://deno.land/std/collections/map_values.ts or https://deno.land/std/collections/mod.ts to be able to use mapValues.

@nayeemrmn
Copy link
Collaborator

Okay I understand, the apiland link was a response to the last thing I said in #1069 (comment).

We can add a setting to preload select remote libs into the ts server so their auto-imports are always available. However, at this point we would only do that for jsr or npm specifiers. With these in Deno, it's no longer worth developing package sniffing infrastructure for arbitrary or favoured https URLs. e.g.:

{
  "deno.preloadPackages": [
    "jsr:@std/path", // Preload all exports in `jsr:@std/path@0.219.0`.
    "jsr:@std/fs/.", // Preload only the default export in `jsr:@std/fs@0.219.0`.
    "jsr:@std/fs/expand-glob", // Preload only the `expand-glob` export in `jsr:@std/fs@0.219.0`.
    "npm:preact" // Preload whatever paths and exports are included in the type declarations for `npm:preact@10.19.3`.
  ]
}

@scarf005
Copy link
Author

scarf005 commented Mar 9, 2024

However, at this point we would only do that for jsr or npm specifiers. With these in Deno, it's no longer worth developing package sniffing infrastructure for arbitrary or favoured https URLs.

i disagree.

  1. jsr: or npm: specifiers cause vendor lock-in (namely, deno). only URLs are free of vendor lock-in.
  2. there's already existing package sniffing infrastructure (apiland), so it makes more sense to provide preloadPackages for http than jsr.

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