deno icon indicating copy to clipboard operation
deno copied to clipboard

Some dependencies not being resolved when using RsBuild

Open sachaw opened this issue 1 year ago • 3 comments

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:

image

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

sachaw avatar Oct 09 '24 22:10 sachaw

The issue is likely caused by rsbuild not understanding Deno-specific resolution.

marvinhagemeister avatar Oct 10 '24 19:10 marvinhagemeister

Is this not a deno responsibility (nodejs compat) or is this out of scope for some reason?

sachaw avatar Oct 15 '24 07:10 sachaw

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.

marvinhagemeister avatar Oct 15 '24 08:10 marvinhagemeister

It seems we(Rspack) can make a rspack plugin which calls deno_resolver to make it work

hardfist avatar Nov 06 '24 15:11 hardfist

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.

LonelySnowman avatar Feb 09 '25 16:02 LonelySnowman

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 avatar Feb 13 '25 06:02 stormslowly

@stormslowly You are right, I will release the npm version in this week.

LonelySnowman avatar Feb 13 '25 06:02 LonelySnowman