aleclarson / vite-tsconfig-paths

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

tsconfig paths - cannot resolve self. #163

Closed jackmillward closed 2 weeks ago

jackmillward commented 2 weeks ago

Since upgrading from 5.0.1 to 5.1.1, I'm getting an error in relation to a package trying to import itself.

Vite version: 5.4.10

Error: The following dependencies are imported but could not be resolved:
   @ui/lib/utils (imported by <path>/website/packages/ui/src/components/ui/dialog.tsx)

Are they installed?
    at file:///<path>/website/node_modules/.pnpm/vite@5.4.10_@types+node@22.9.0/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:50666:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///<path>/website/node_modules/.pnpm/vite@5.4.10_@types+node@22.9.0/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:50171:26

The project's tsconfig.json looks like:

{
  "extends": "@repo/typescript-config/react-library.json",
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@ui/*": ["./src/*"]
    }
  },
  "include": ["src"],
  "exclude": ["node_modules"]
}

This works in 5.0.1, no problem at all.

I've tried the "loose": true and "allowJs": true options as in the change for the new version but this hasn't helped.

aleclarson commented 2 weeks ago

This might be fixed in v5.1.2 so please test it and let me know 👍

jackmillward commented 2 weeks ago

This might be fixed in v5.1.2 so please test it and let me know 👍

Brilliant, thank you. All fixed!