oven-sh / bun

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

Implement esbuild `packages` option in bun bundler #12293

Open huseeiin opened 4 days ago

huseeiin commented 4 days ago

What is the problem this feature would solve?

sometimes, we want to bundle all of our local imports (i.e. ./utils.js) but not our node_modules (i.e. svelte)

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

Implement esbuild packages: "external" option https://esbuild.github.io/api/#packages

What alternatives have you considered?

import pkg from "./package.json";

Bun.build({
  external: Object.keys(pkg.dependencies),
});
paperdave commented 3 days ago

i like this

huseeiin commented 3 days ago

i like this

Basically its like a transpiler but only bundles local imports. another example is tsup (built on esbuild), it externalizes all devDependencies without even asking it.