denoland / vscode_deno

Visual Studio Code plugin for Deno
https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno
MIT License
1.5k stars 146 forks source link

Import maps not recognized for nested deno projects #1117

Closed nandorojo closed 6 months ago

nandorojo commented 6 months ago

Describe the bug

If you have a Deno project in a sub-folder of your repository, then its deno.json won't get recognized. It looks like the VSCode Extension only checks the root of your project for a deno.json file. However, it should also be checking deno.enablePaths locations.

As a result, monorepos using deno cannot use imports properly.

Screenshot 2024-05-17 at 11 41 36 AM

To Reproduce

  1. Create a subfolder, like ./projects/deno
  2. In .vscode/settings.json, enable Deno and add deno.enablePaths: './projects/deno'
  3. Add a deno.json file at ./projects/deno/deno.json
  4. In deno.json, add imports like so:
{
  "imports": {
    "~public/": "./public/"
  }
}
  1. Create a file at ./projects/deno/public/test.ts: export default 1
  2. Create a file at ./projects/deno/root.ts: import test from '~public/test.ts
  3. Watch as it errors.

Workaround: Open ./projects/deno in VSCode directly (not desired).

Expected behavior

Import paths should work relative to the location of the deno.json file. And in fact, they do. However, the VSCode extension doesn't seem to pick them up.

The workaround is to open the nested folder in VSCode directly. However, this is a workaround at best.

Screenshots

See above.

Versions

vscode: 1.89.1 deno: 1.43.3 extension: v3.37.1

Thank you for your help.

nayeemrmn commented 6 months ago

Tracked in #787.