You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that it's practical to use Playwright with bun (#2492), it's possible to move fairly complicated web projects entirely to bun. This presents an opportunity to implement a feature that npmdeclined 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:
bandwidth,
download time, and
disk space
when these are not needed.
What is the feature you are proposing to solve the problem?
Support an optionalDevDependencies field in package.json.
Fall back to true when optional and dev are both true.
Fall back to false if either optional or dev is false.
This allows projects to have a "quick start" dev process without any hacks, by using setup steps with different bun install config files:
# Get started quickly
git clone https://github.com/cubing/cubing.js &&cd cubing.js
make quick-setup dev
make test-fast # Run a large range of quick tests# Install all dev dependencies to run browser tests
make setup test-all
# Potential Makefile example.PHONY: quick-setup:
quick-setup:
bun install --config bunfig-quick.toml
.PHONY: setup:
setup:
bun install # default config
What alternatives have you considered?
In theory it's possible to use a library for this, but that would require either:
vendoring the library code (a maintenance and security liability), or
installing the library (requires two separate install steps, likely to be slower and still kind of complicated).
By contrast, it would be really valuable as built-in functionality for the package manager so that projects can hit the ground running.
The text was updated successfully, but these errors were encountered:
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.
Footnotes
And I must commend bun install on being wicked fast when the dependencies are already cached. ↩
What is the problem this feature would solve?
Now that it's practical to use Playwright with
bun
(#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.
The text was updated successfully, but these errors were encountered: