Open lgarron opened 7 months ago
This allows projects to have a "quick start" dev process without any hacks by using setup steps with different
bun
install config files:
In particular, cubing.js
already does this by manually emulating optional dev dependency functionality.
If I set Network Link Conditioner to 20mbps, then I see a significant difference when installing all dev dependencies using bun install
:
git clone https://github.com/cubing/cubing.js && cd cubing.js
make clean && rm -rf node_modules && bun pm cache rm
time make quick-setup test-fast # ≈ 12 seconds
git clone https://github.com/cubing/cubing.js && cd cubing.js
make clean && rm -rf node_modules && bun pm cache rm
time make setup test-fast # ≈ 120 seconds
This shows that someone can get started in the project about 10× as fast using optional dev dependencies if they have no dependencies cached. 😱 With a slower connection (say, 3G connection speed, or slow shared Wi-Fi), this can make a huge difference — even if some dependencies are already cached, it could be a difference of many minutes.
bun
already makes the local operations fast [^1], but this would help make the overall experience of project development faster starting from right after checkout.
[^1]: And I must commend bun install
on being wicked fast when the dependencies are already cached.
The workaround for this would be a git branch, but it'd be very cumbersome to maintain.
What is the problem this feature would solve?
Now that it's practical to use Playwright with
bun
(https://github.com/oven-sh/bun/issues/2492), it's possible to move fairly complicated web projects entirely tobun
. This presents an opportunity to implement a feature thatnpm
declined to implement: optional dev dependencies.Dependencies like Playwright can be fairly large. They are valuable in CI or for thorough testing, but not needed for everyday development or a small PR. The same applies to special tools that are only run when deploying or publishing code.
I would love to avoid making everyone download these large dependencies and potentially save significant:
when these are not needed.
What is the feature you are proposing to solve the problem?
optionalDevDependencies
field inpackage.json
.bun install
configuration, add anoptionalDev
field.optionalDev
is not specified:true
whenoptional
anddev
are both true.false
if eitheroptional
ordev
isfalse
.This allows projects to have a "quick start" dev process without any hacks, by using setup steps with different
bun
install config files:What alternatives have you considered?
In theory it's possible to use a library for this, but that would require either:
By contrast, it would be really valuable as built-in functionality for the package manager so that projects can hit the ground running.