esbuild
esbuild copied to clipboard
re-create package.json with only externalized dependencies
trafficstars
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.