evanw / evanw/esbuild

re-create package.json with only externalized dependencies

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

Description

**Problem 1:**

i am using esbuild with externalized packages:

```
esbuild ./src/index.ts --bundle --outfile=./dist/index.js --platform=node --keep-names --packages=external
```

externalizing packages is needed because some modules may rely on a certain folder structure and may not work correctly when bundled.

Local dependencies in a monorepo get bundled with this, which is nice.

However you still need to install certain packages, but if you use the original package.json, you may have local dependencies there that can't be installed after bundling with esbuild.

**Problem 2**

When you just externalize _some_ packages and bundle others, you still have a package.json that contains all dependencies.

**Solution**:

- **lowlevel**: have an option to list all packages that have been externalized and/or bundled. With this, you could do further manipulate the package.json to include or remove just those packages
- **sophisticated**: have an option to generate a stripped down package.json that only contains the prod-dependencies that are actually needed.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the esbuild command shown in the issue and how it handles package.json when packages are externalized or bundled. Compare the lowlevel externalized-package listing with the sophisticated stripped-down package.json proposal; done means a defined option and dependency output that supports the described monorepo and partially externalized cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, javascript, node.js, typescript
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.