Skip to content
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

re-create package.json with only externalized dependencies #3744

Open
macrozone opened this issue Apr 30, 2024 · 0 comments
Open

re-create package.json with only externalized dependencies #3744

macrozone opened this issue Apr 30, 2024 · 0 comments

Comments

@macrozone
Copy link

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant