vscode_deno icon indicating copy to clipboard operation
vscode_deno copied to clipboard

Feat: Quick Fix: Extract to import map

Open marvinhagemeister opened this issue 7 months ago • 1 comments

Is your feature request related to a problem? Please describe.

I find myself often in the situation where I'm prototyping something and using npm: or https:// imports for convenience. Once a dependency needs to be shared among files I typically want to move them to a single place to version them. So far I've always manually pasted and replaced the identifier, but I feel like it's something vscode should be able to do for me.

Describe the solution you'd like

A new quick fix command for npm: or https:// import specifiers that extracts it to the import map.

// Before
import { render } from "npm:[email protected]";

// After
import { render } from "preact";

// deno.json
{
  "imports": {
    "preact": "npm:[email protected]",
  }
}

marvinhagemeister avatar Nov 28 '23 10:11 marvinhagemeister

I want this for a while! Also perhaps handle other files with the same import (or similar import with a different version) via some code-action. This could help make the whole codebase nicer quickly.

guy-borderless avatar Dec 14 '23 15:12 guy-borderless