vite_plugin_deno_resolve
vite_plugin_deno_resolve copied to clipboard
Vite react plugin doesn't work as it can't find dependencies
Two problems currently:
- Prebundling can't find the dependencies (react, react/jsx-runtime, react/jsx-dev-runtime) as it's currently hardcoded in Vite to use the node resolver. We can "work around this" by removing them from
config.optimizeDeps.include
duringconfigResolved
step - After doing that there is... still problems. Same issue basically.
2:28:45 pm [vite] Internal server error: Failed to resolve import "react/jsx-dev-runtime" from "react/jsx-dev-runtime". Does the file exist?
🤔
Initial way forward: Don't use it. Next way forward: Fork? Future way forward: Contribute to the plugin to make it work with Deno?
Prebundling can't find the dependencies (react, react/jsx-runtime, react/jsx-dev-runtime) as it's currently hardcoded in Vite to use the node resolver. We can "work around this" by removing them from config.optimizeDeps.include during configResolved step
How do you force prebundling @itsdouges? It seems the problem is that esbuild can't find this dependencies, which would be handled by providing a similar resolver to esbuild so it can search through Deno's cache.
I was digging through the optimizer code and saw it instantiates the node resolve plugin there so I made the assumption that's what's happening 🤔
Im not sure if this is forcing prebundling but the includes array can take any package name, similar to dedupe.
I was digging through the optimizer code and saw it instantiates the node resolve plugin there so I made the assumption that's what's happening 🤔
Im not sure if this is forcing prebundling but the includes array can take any package name, similar to dedupe.
Could you show me your configuration? I can't get it to work in any way...
https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/src/index.ts#L394
This?
Thanks, I took a stab at it and running into some very strange problems arising from my lack of knowledge on Vite internals. I'll try to get send some questions towards Vite maintainers to get more info what is expected from our side.