aleclarson / vite-tsconfig-paths

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

Compatability with Vite 4.3.x? #110

Closed jafin closed 10 months ago

jafin commented 1 year ago

I have a project that was running Vite 4.2.2, upgraded to Vite@4.3.1 Now when I run it appears the tsconfig aliases no longer work.

"vite-tsconfig-paths": "^4.2.0",
"@vitejs/plugin-react": "4.0.0",
"vite": "^4.3.1",
Error: The following dependencies are imported but could not be resolved:

  @pages/profile/profile (imported by D:/Data/_Code/src/Routes.tsx)
  @components/gallery/gallery ...

If I revert to Vite 4.2.2 it all works again.

my tsconfig.paths.json looks like this

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "@components/*": ["components/*"],
      "@pages/*": ["pages/*"]
    }
  }
}

TBH Not sure if this is related to this plugin or vite 4.3x in general...

aleclarson commented 1 year ago

It's a vite bug. There was a huge refactor of the module resolution logic in 4.3

fwouts commented 1 year ago

@aleclarson is there a corresponding issue in the Vite repo already? If not how can we help?

Edit: from debugging, it looks like the issue is that resolveId() is called with a value for importer that isn't a fully resolved ID anymore, breaking the Rollup plugin API contract?

Lilja commented 1 year ago

Has the bug been solved now? There's a reference to this thread in the vite repo with a PR that's merged. But I'm still having the same issue.

rtmann commented 1 year ago

Lots of finger pointing here, no real path to resolution. We reverted to 4.2.2 and our CIDC pipeline works now. Weird though that 4.5.0 works fine locally, but not in the cidc. This plugin only fails in our cidc pipeline, same OS, same Node, Same yarn version, same environment variables, it fails on cidc in azure, but locally on windows in the same setup it works...

But if we revert to 4.2.2 it works in azure on our build agent.

Weird. I can't explain why it works locally, but not in the build agent...

mister-teddy commented 5 months ago

Lots of finger pointing here, no real path to resolution. We reverted to 4.2.2 and our CIDC pipeline works now. Weird though that 4.5.0 works fine locally, but not in the cidc. This plugin only fails in our cidc pipeline, same OS, same Node, Same yarn version, same environment variables, it fails on cidc in azure, but locally on windows in the same setup it works...

But if we revert to 4.2.2 it works in azure on our build agent.

Weird. I can't explain why it works locally, but not in the build agent...

@rtmann Did you eventually find out why? I ran into the same issue but with Vite 5. Things worked on Mac and Linux, but on Windows, when running using VS Code Extension Host (which is Node 18), I got the above error 🫤

It was even more strange that things worked the first time I started the development server (using createServer, the JavaScript API, not Vite CLI). Then I stopped the server, and things went wrong from the second start. When using build, things went wrong from the first. So I guess "reusing" Vite for multiple jobs was not an issue here.