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

Automatically install npm packages when running a script in Bun's runtime #1459

Merged
merged 33 commits into from
Nov 7, 2022

Conversation

Jarred-Sumner
Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner commented Nov 5, 2022

This enables automatically installing npm packages used in a script and resolving from a global shared cache when no node_modules folder is present.

It works:

  • with and without package.json
  • with and without lockfiles

package.json can be used the same as with node_modules. The version ranges specified in the package.json for dependencies become the default used in the runtime. This makes it so you don't have to run npm install or bun install to install dependencies in Bun's runtime. There is no special syntax.

image

TODO:

  • Tests
  • Error handling
  • Disable version specifier support when a package.json is present
  • Update README for changes
  • Load lockfile from nearest package.json
  • Enable progress bar
  • Save lockfile
  • Add a flag that enables it even if a node_modules folder is present. Useful for monorepos with a <workspace>/scripts folder. Thinking something like: (cc @colinhacks), though they might actually put it in "scripts" within package.json
bun -i scripts/extract-tps-reports.js

Out of scope for this first release:

  • TypeScript support (generate .d.ts)
  • Nested lockfiles

src/cli.zig Outdated Show resolved Hide resolved
@Jarred-Sumner
Copy link
Collaborator Author

Some of the errors:
image
image
image

Bug where error message is different if cached. I think we should ship with this known bug in the initially because fixing it is a pain and it's still informative
image

@Jarred-Sumner
Copy link
Collaborator Author

spinner

asdasdasd

@Jarred-Sumner
Copy link
Collaborator Author

Still need to write tests, but there's enough conflicting changes that I'm going to go ahead and merge it

@Jarred-Sumner Jarred-Sumner merged commit e45f72e into main Nov 7, 2022
@Jarred-Sumner Jarred-Sumner deleted the jarred/install branch November 7, 2022 05:42
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

Successfully merging this pull request may close these issues.

None yet

2 participants