New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bun build --external
option to treat all node_modules packages as external
#6351
Comments
Until there is a way to treat all node_modules as external, I am using this build script which populates external from package.json:
Despite trying to be very careful with keeping my external in sync manually, when I ran this script for the first time on one project with dependencies that started getting long, I found I had missed one just reinforcing how error prone it is. |
bun build --external
option to treat all node_modules packages as extenralbun build --external
option to treat all node_modules packages as external
+1 for this feature. I often use Bun to minify individual files, so having an option like |
I suggest this syntax: bun build ./src/foo.ts --external='*,!./*,!../*' (external = all ( |
here is fixed function getExternalsFromPackageJson() {
const packageJson = JSON.parse(fs.readFileSync("./package.json"))
const sections = [
'dependencies',
'devDependencies',
'peerDependencies',
], externals = new Set()
for (const section of sections)
if (packageJson[section])
Object.keys(packageJson[section]).forEach(_ => externals.add(_))
console.log('externals', externals)
return Array.from(externals)
} then use in build config: |
What is the problem this feature would solve?
When building node/electron packages in a monorepo it's often useful to treat anything in node_modules as external as you don't want to bundle your local dependencies. Currently you have to manually specify
--external=
for every package you want to make external, which is error-prone and tedious.What is the feature you are proposing to solve the problem?
This is similar to this esbuild feature request: evanw/esbuild#619
What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: