Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot be used when using later versions of esbuild (via Vite for example) #4

Open
kevinvalk opened this issue Jun 7, 2024 · 0 comments

Comments

@kevinvalk
Copy link

Esbuild v0.21.4 introduced a small change.

Pass import attributes to on-resolve plugins

This sadly breaks types with older versions of Esbuild and I started getting this error on build:

16.16 vite.config.ts(153,11): error TS2322: Type 'import("/node_modules/esbuild/lib/main").Plugin' is not assignable to type 'import("/node_modules/vite/node_modules/esbuild/lib/main").Plugin'.
16.16   Types of property 'setup' are incompatible.
16.16     Type '(build: import("/node_modules/esbuild/lib/main").PluginBuild) => void | Promise<void>' is not assignable to type '(build: import("/node_modules/vite/node_modules/esbuild/lib/main").PluginBuild) => void | Promise<void>'.
16.16       Types of parameters 'build' and 'build' are incompatible.
16.16         Type 'import("/node_modules/vite/node_modules/esbuild/lib/main").PluginBuild' is not assignable to type 'import("/node_modules/esbuild/lib/main").PluginBuild'.
16.16           Types of property 'onResolve' are incompatible.
16.16             Type '(options: import("/node_modules/vite/node_modules/esbuild/lib/main").OnResolveOptions, callback: (args: import("/node_modules/vite/node_modules/esbuild/lib/main").OnResolveArgs) => import("/node_modules/vite/node_modules/esbuild/lib/main").OnResolveResult | ... 2 more ... | undefined) => void' is not assignable to type '(options: import("/node_modules/esbuild/lib/main").OnResolveOptions, callback: (args: import("/node_modules/esbuild/lib/main").OnResolveArgs) => import("/node_modules/esbuild/lib/main").OnResolveResult | Promise<...> | null | undefined) => void'.
16.16               Types of parameters 'callback' and 'callback' are incompatible.
16.16                 Types of parameters 'args' and 'args' are incompatible.
16.16                   Property 'with' is missing in type 'import("/node_modules/vite/node_modules/esbuild/lib/main").OnResolveArgs' but required in type 'import("/node_modules/esbuild/lib/main").OnResolveArgs'.

I think the idea is to use peerDependencies for this. That said, I have no clue how this resolves if vite uses its own esbuild version. Is node module resolver smart enough to use that esbuild, I would assume so?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant