oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.35k stars 2.78k forks source link

`--packages external` should bundle workspace members #15327

Open mattfysh opened 7 hours ago

mattfysh commented 7 hours ago

What is the problem this feature would solve?

This would allow a more logical definition of what is an external package, and what should be included in a bundle

What is the feature you are proposing to solve the problem?

When using bun build --packages external any workspace members should not be externalized. An example is available here: https://github.com/mattfysh/bunpkgsext

packages/a depends on packages/b and lodash - when bundling A with --packages external it externalizes both B and lodash. Because package B is a workspace member and not a third party package, it should not be excluded from the bundle

This would also bring bun in line with esbuild

What alternatives have you considered?

  1. Manually listing each node_module as --external -- too fussy and error prone
  2. Writing a plugin to decide which packages to externalize