evanw / evanw/esbuild

Is there any harm in marking all my dependencies and devDependencies from my package.json set to "external" (for Electron app)?

Open
#2,297 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
40.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

I have seen a few examples that use the concept of excluding library code from node modules during the compile/bundle process with the `external` option adding all package dependencies from the `package.json`. I am wondering if there is any harm in this or anything I need to be careful with? Below is the code I am using in my esbuild config script for an `electron` app. I build a list of `externalPackages` to exclude by reading the `package.json` and grabbing all dependencies and then adding to that list all the built in node modules.

Thoughts? Anything I could improve here or need to be mindful of? Bad idea? Good idea?

```js
import { build } from 'esbuild';
import { readFileSync } from 'fs';
import nodeModule from 'node:module';

let { dependencies, devDependencies, peerDependencies } = JSON.parse(readFileSync('./package.json', 'utf8'));
let externalPackages = Object.keys(!dependencies ? {} : dependencies)
.concat(Object.keys(!devDependencies ? {} : devDependencies))
.concat(Object.keys(!peerDependencies ? {} : peerDependencies))
.concat(...nodeModule.builtinModules);

build({
...
external: externalPackages,
...
}).catch(() => process.exit(1));
```

Contributor guide

No contributing guide indexed for this repository

Research direction

The question centers on the esbuild config script, package.json, and node:module's builtinModules. Start by checking esbuild's external-option documentation and reproducing the Electron build with the listed dependency groups. Done means recording clear guidance about external packages and the runtime packaging constraints identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, javascript, node.js
Domain
build-system, desktop
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.