Open joy-stacks opened 5 months ago
NestJS uses optional/peer dependencies for many modules, such as "@nestjs/microservices" and "class-validator" in your example.
To efficiently compile, bun needs to bundle all modules required by the code, even the ones you don't actually use. Have you tried installing all these libraries before compiling? It may fix the problem in the meantime. You could also set all these dependencies as "external" in your build step I guess.
However, it would be nice to allow compilation with these unknown modules. Maybe with a flag like "--allow-missing-deps" or something? And it would also be nice to document this behavior.
NestJS uses optional/peer dependencies for many modules, such as "@nestjs/microservices" and "class-validator" in your example.
To efficiently compile, bun needs to bundle all modules required by the code, even the ones you don't actually use. Have you tried installing all these libraries before compiling? It may fix the problem in the meantime. You could also set all these dependencies as "external" in your build step I guess.
However, it would be nice to allow compilation with these unknown modules. Maybe with a flag like "--allow-missing-deps" or something? And it would also be nice to document this behavior.
thanks
With v1.1.21 there's the new --packages=external
flag. I didn't test it, but since the problem is due to optional dependencies, I bet it would solve the issue if it can be coupled with --compile
.
Still, it would be nice to document that compilation with missing packages (add a warning about optional and peer dependencies, which are the most likely to trigger this) crashes. And that you have to either add the --packages=external
flag, manually set the not-needed packages as externals, or install all of them.
I'm still rooting for an --allow-missing-deps
flag of some sort, but that's probably just me.
What version of Bun is running?
1.1.13
What platform is your computer?
windows x64
What steps can reproduce the bug?
bun run src/main.ts
successbut
bun build src/main.ts --compile
failedWhat is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response