Some dependencies not being resolved when using RsBuild
Version: Deno 2.0.0
Hi, Take the following RsBuild + SolidJS repo running under Deno:
https://github.com/sachaw/rsbuild-issue
When running deno install, as "nodeModulesDir": "auto" is set, it is populated as follows:
As can be seen modules like date-fns are populated at the root level, and hence are located and compile fine under RsBuild.
Now take my next dependency: @dewars/protobufs which is published to JSR:
It is resolved by my IDE (because of the Deno plugin), but is not populated in my node_modules folder, leading RsBuild to fail to resolve it.
Ideally I can eventually ditch the whole node modules folder, so I'm hoping the solution isn't to copy all of my native deno deps under node_modules
The issue is likely caused by rsbuild not understanding Deno-specific resolution.
Is this not a deno responsibility (nodejs compat) or is this out of scope for some reason?
Every bundler has their own resolution code and rspack/rsbuild always expects a dependency to be in the node_modules folder as it assumes that every dependency is an npm dependency. That assumption is not something we can fix on the Deno side.
It seems we(Rspack) can make a rspack plugin which calls deno_resolver to make it work
https://github.com/LonelySnowman/rspack-deno-plugin
@sachaw I developed an rspack plugin to solve this problem. I hope it will be helpful to you.
it's ok to use like in your readme
but i have another problem in the original issue
After i add import RspackDenoPlugin from '@snowman/rspack-deno-plugin'; to the config file, then run deno task build
error Cannot find module '@snowman/rspack-deno-plugin'
in my opinion a npm version of @snowman/rspack-deno-plugin is needed, so user can rspack/rsbuild in deno task easily like npm script.
@stormslowly You are right, I will release the npm version in this week.