bartlomieju / vite-deno-example

Example of using Vite with Deno
https://vite-deno-example.deno.dev
163 stars 7 forks source link

Relative import path "vue" not prefixed with / or ./ or ../ #5

Open sistematico opened 1 year ago

sistematico commented 1 year ago

VSCode is showing error on import. The app is running fine BTW.

image

Fresh install. Any help is welcome.

itsdouges commented 1 year ago

I have this problem as well. What's the go for deno to type check these properly? Is it that vite needs to be taught about npm specifiers and currently it's not, so we're using a hack by importing all dependencies in the deno entrypoint instead, thus causing node_modules to be populated, and then finally vite can pick up the standard dependencies...?

Any suggestions to get type checking working ATM?

sistematico commented 1 year ago

Related: https://github.com/denoland/vscode_deno/issues/261#issue-749215936

itsdouges commented 1 year ago

Ah interesting, using import maps does work for me. Thanks! I suppose that's one solution for now (ignoring the auto complete issue).

sistematico commented 1 year ago

Ah interesting, using import maps does work for me. Thanks! I suppose that's one solution for now (ignoring the auto complete issue).

You can share your import_map.json?

itsdouges commented 1 year ago
{
  "imports": {
    "@faze/editor-backend": "./packages/editor-backend/mod.ts",
    "@faze/editor-cli": "./packages/editor-cli/mod.ts",
    "@faze/editor-frontend": "./packages/editor-frontend/mod.ts",
    "@react-three/drei": "npm:@react-three/drei@9.45.0",
    "@react-three/fiber": "npm:@react-three/fiber@8.9.1",
    "react-dom": "npm:react-dom@18.2.0",
    "react-router-dom": "npm:react-router-dom@6.4.4",
    "react": "npm:react@18.2.0",
    "three": "npm:three@0.144.0",
    "three-stdlib": "npm:three-stdlib@2.20.4"
  }
}

With deno json

{
  "importMap": "./import_map.json",
  "tasks": {
    "editor": "deno run --allow-run packages/editor-cli/mod.ts"
  },
  "compilerOptions": {
    "jsx": "react-jsx",
    "lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"],
    "types": ["vite/client", "./types/vite.d.ts"]
  }
}
sistematico commented 1 year ago

Thank you.

bartlomieju commented 1 year ago

Unfortunately it is currently not supported in Deno extension to type check the code that has no npm: prefix or is not specified in the import map. We'll be looking into sorting this situation after NYE.