aleclarson / vite-tsconfig-paths

Support for TypeScript's path mapping in Vite
MIT License
1.28k stars 45 forks source link

missing baseUrl #44

Closed hzhang1902 closed 2 years ago

hzhang1902 commented 2 years ago

I am using tsconfig path to import a file outside of project root, like:

"paths": {
      "shared/*": [
        "../shared/*"
      ],
    }

this is working on other webpack/esbuild projects, but not with this plugin. I used debug mode and logged the following error:

vite-tsconfig-paths crawling "/Users/admin/.../my-project" +0ms
vite-tsconfig-paths options: {
  projects: [ '/Users/admin/.../my-project/tsconfig.json' ],
  extensions: [ '.ts', '.tsx', '.js', '.jsx', '.mjs' ]
} +4ms
vite-tsconfig-paths [!] missing baseUrl: "/Users/admin/.../my-project/tsconfig.json" +4ms

and vite throws the error as if the plugin is not used

Error: The following dependencies are imported but could not be resolved:
aleclarson commented 2 years ago

The docs for TypeScript say that baseUrl is required if paths is used. https://www.typescriptlang.org/tsconfig/#paths

aleclarson commented 2 years ago

Fixed in v3.4.0