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

Bun support #295

Open
KyleSanderson opened this issue Aug 24, 2023 · 20 comments · May be fixed by #307
Open

Bun support #295

KyleSanderson opened this issue Aug 24, 2023 · 20 comments · May be fixed by #307

Comments

@KyleSanderson
Copy link

Hi there,

I have no relation to the bun team at all (and, am a bit daft on web stuff). I'm looking to change to bun from pnpm for performance reasons, but there's no way to do this through the corepack system today (which has been very kind to me, for what it's worth).

It would be very nice if I could use the corepack mechanism to change to bun, similar to how (p)npm are implemented today from yarn.

https://github.com/oven-sh/bun
https://bun.sh/

It looks like they have a 1.0 mark coming on September 7th 2023.

@ljharb
Copy link
Member

ljharb commented Aug 24, 2023

bun is a replacement runtime for node, it's not a standalone package manager.

@KyleSanderson
Copy link
Author

bun is a replacement runtime for node, it's not a standalone package manager.

I'm under the impression it is a package manager per https://bun.sh/docs/cli/install

I understand it may compete in areas, but the once corepack installs it, it (bun) runs the same way for a project that pnpm does.

@ljharb
Copy link
Member

ljharb commented Aug 24, 2023

it contains one, but there's no standalone "bun package manager" - it can't run inside node, so to use it you'd have to install the entirety of bun.

@KyleSanderson
Copy link
Author

KyleSanderson commented Aug 24, 2023

it contains one, but there's no standalone "bun package manager" - it can't run inside node, so to use it you'd have to install the entirety of bun.

I think it's just a single statically linked binary, no? I think what I'm looking for is for corepack to install the binary for me (similar to (p)npm) and that's it.

EDIT: I just read their docs, looks like it's installable through npm as well: npm install -g bun

@uncenter
Copy link

Any update on this? 1.0 just came out the other day.

@azu
Copy link

azu commented Sep 11, 2023

For reference, the meta-npm package managers (ni and ni.zsh) recognise bun as a package manager.
I think bun is an npm package manager because it has commands similar to most package managers and can handle npm packages.

Command Table
npm yarn yarn-berry pnpm bun
npm install yarn install yarn install pnpm install bun install
npm install yarn add yarn add pnpm add bun add
npm uninstall yarn remove yarn remove pnpm remove bun remove
npm run yarn run yarn run pnpm run bun run
npm run test yarn run test yarn run test pnpm run test bun run test
npm upgrade yarn upgrade yarn up pnpm update bun update
-- yarn upgrade-interactive yarn up -i pnpm update -i --
npm exec yarn <command> yarn exec pnpm exec bunx
npx -- yarn dlx pnpm dlx bunx

There is a desire to simply write "packageManager" : "[email protected]" on package.json.

@aduh95
Copy link
Contributor

aduh95 commented Sep 11, 2023

For a new package manager to be added, someone needs to open a PR adding it to the config.json, optionally update the automation so the config is updated automatically when new versions are released, and make sure all the tests pass.

@Ethan-Arrowood Ethan-Arrowood linked a pull request Sep 11, 2023 that will close this issue
styfle added a commit to vercel/vercel that referenced this issue Sep 11, 2023
> [!IMPORTANT]  
> This PR will only support Bun as a package manager at build time. 
> Bun will **not** work at runtime with Serverless Functions or Edge
Functions at this time.

- Depends on vercel/api#21869
- Fixes https://github.com/orgs/vercel/discussions/2021
- Closes #10244
- Related nodejs/corepack#295
- Docs https://bun.sh/docs/install
@TheDanielMoli
Copy link

Looking forward to this, I'll try to do it myself next month (if not out yet)

@SilverLinings89
Copy link

We are using bun in several repos and it would be awesome to be able to specify it as the packageManager (and have that actually do something :) ).

@strafe
Copy link

strafe commented Feb 27, 2024

Hey, you're that one SourceMod guy!

On topic, bun's website is littered with references to it being usable solely as a package manager:

https://bun.sh/package-manager

Compatibility with Node.js or Bun.
Bun's package manager is intended for use as a standalone tool, regardless of whether you're using the Bun runtime. It'll work in any project with a package.json, and it supports workspaces, git/http/tarball dependencies, custom registries, and more.

image

@ovflowd
Copy link
Member

ovflowd commented Apr 1, 2024

Out of curiosity, what is "adding bun" to Corepack supposed to mean? 🤔

Bun is a JavaScript runtime that also bundles itself a package manager but the package manager doesn't seem to be available standalone without the rest of the Bun runtime.

Apparently, Bun maintainers also explicitly asked to not have their binaries added to Corepack.

I assume this means we should not proceed with this.

(It would feel at the very least weird for Node.js as a JavaScript runtime to ship another runtime inside itself)

@TheDanielMoli
Copy link

Yes, bun is a full runtime but it can be used as “just a package manager” while still running things on Node. It’s faster than npm, faster than yarn and faster than pnpm.

Corepack warns users that are trying to install dependencies with a different package manager that they are doing something wrong. For example, if I set pnpm through corepack, I can make it throw an error to users who try to install dependencies with yarn.

This won’t work when using bun as a package manager, because it’s not supported by corepack.

@ovflowd
Copy link
Member

ovflowd commented Apr 1, 2024

I genuinely don't think Bun should be part of Corepack. Unfortunately Corepack's own documentation doesn't have a concrete process or what "is a package manager"; albeit is also not up to me to decide what it is or not as I am not a Corepack contributor; Having that said, having Bun as a package manager within Node feels somewhat a conflict of interest, or at least so it does to me. But that's just my interpretation and it doesn't really matter.

What matters is that Bun maintainers opted on not wanting Bun yo be shipped by Node through Corepack and that's within their right to do, and pretty much within their rights of LICENSE; (We are having the same discussion regarding npm at the moment)

I definitely appreciate and believe Corepack should support more package managers, but I believe it should go with the caveats that the authors of such piece of software should agree with having their software binaries being shipped by a third party software.

This is just my interpretation of things, but genuinely I believe some sort of governance or requirements should be set in place of what should be allowed or not to be added within Corepack 🤔

@SilverLinings89
Copy link

I don't precisely know how corepack works so I don't want to speculate too much but from what I know, node also doesn't ship yarn. However, corepack can detect if yarn is being used and inform a user to do so if it is set as the packageManager. The same would be nice for bun. In our project, we don't use bun as a runtime very much but we do rely on its performance as a package manager to speed up our pipelines.

@SilverLinings89
Copy link

I really don't think anybody wants node to ship bun, only to enable corepack to check if it's being used if it is specified as the packageManager.

@ovflowd
Copy link
Member

ovflowd commented Apr 1, 2024

I really don't think anybody wants node to ship bun, only to enable corepack to check if it's being used if it is specified as the packageManager.

I see. That makes sense to me.

Also to be clear, my commentary is just me trying to make sense of what the ask here is. Im not speaking on behalf of the project, nor blocking these changes from happening.

@TheDanielMoli
Copy link

I really don't think anybody wants [...] only to enable corepack to check if it's being used if it is specified as the packageManager

Actually, this is exactly what we would like, what we are looking for and the only reason why I am using corepack.

Your assumption on what users are looking for in corepack is wrong. Forcing a package manager on a per-project basis by specifying it in package.json is exactly what I am looking for as a corepack user (aka, failing when trying to use a different one).

@SilverLinings89
Copy link

Sorry, you are misquoting me here. The comma before only was there for exactly that reason. To rephrase my statement without a subordinate clause:
I really don't think anybody wants node to ship bun. I think they only want to enable corepack to check if it's being used if it is specified as the packageManager.

@KaKi87
Copy link

KaKi87 commented May 10, 2024

The local project doesn't define a 'packageManager' field. Corepack will now add one

Except whatever it suggests is wrong : I'm using Bun. What to do now ?

@ovflowd
Copy link
Member

ovflowd commented May 11, 2024

The local project doesn't define a 'packageManager' field. Corepack will now add one

Except whatever it suggests is wrong : I'm using Bun. What to do now ?

Who exactly are you quoting here?

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 a pull request may close this issue.

10 participants