Closed tervay closed 10 months ago
yep, I also encounted with this issue on vite with version v5.0.10.
Unfortunately can confirm that it seems to be broken in Vite 5.
TypeScript error:
No overload matches this call.
The last overload gave the following error.
Type 'Plugin<any>' is not assignable to type 'PluginOption'.
vite-tsconfig-paths v3.6.0 downgrades will normal operation.
I could not reproduce with the given StackBlitz, @tervay. I also tried reproducing manually, but no luck. Please try clearing your node_modules, deleting your lockfile, and re-installing to see if that fixes it for you. Otherwise, please provide a proper reproduction, thanks.
@aleclarson The stackblitz will fail when running yarn build
. I'm not sure how to make it run that by default instead of yarn run dev
, but yarn build
will fail.
I'm having the same issue. It fails only when used as a worker plugin. Just like in the provided StackBlitz.
I could not reproduce with the given StackBlitz, @tervay. I also tried reproducing manually, but no luck. Please try clearing your node_modules, deleting your lockfile, and re-installing to see if that fixes it for you. Otherwise, please provide a proper reproduction, thanks.
The error only shows when you run the build command:
The error happens at this line: https://github.com/aleclarson/vite-tsconfig-paths/blob/dd3fc7e9ef353b0f53dc9720c00e722ad35f5104/src/index.ts#L164
My insight on this is that resolveId
is being called before configResolved
, or configResolved
is not being called at all on the worker plugin. That way this line is not executed https://github.com/aleclarson/vite-tsconfig-paths/blob/dd3fc7e9ef353b0f53dc9720c00e722ad35f5104/src/index.ts#L125 and it ends up in the error since it's undefined
.
I was able to workaround it by passing the same plugin object to both arrays, since it uses the same tsconfig for workers and main project. That way the resolversByDir
gets prepopulated on the configResolved
of the main plugin.
const tspaths = tsconfigPaths()
export default defineConfig({
plugins: [tspaths],
worker { plugins: () => [tspaths] },
})
This is a bug in Vite. I've opened this PR to fix it. Thanks for investigating, @davbrito. Neither of your suspicions were correct, but it helped save me some time. 👍
Closing this. The Vite PR has been merged. Not sure what the release schedule is these days. If you have any other problems with Vite 5 and this plugin, open a new issue.
https://stackblitz.com/edit/vitejs-vite-2pijh9?file=package.json
This stackblitz resembles a project structure I'm using that no longer works with Vite 5. In Vite 4, this project will (intentionally, in this Stackblitz case) fail due to a top-level await not being allowed in the configured environment (which is fine, expected, and desired in this case).
With Vite 5.0.2, this fails with the following stack trace:
I'm not familiar enough with Vite to further debug this.