nx icon indicating copy to clipboard operation
nx copied to clipboard

feat(core): add bun package manager

Open Jordan-Hall opened this issue 10 months ago • 31 comments

Bun uses yarn lock for it's binary file. Running the binary will produce the content of a yarn lock file (v1)

Other option is to use the -y command on add and install. This will create a yarn lock file and then createLockFile can just modify the yarn.lock file instead?

This is the PR made from #19113 and pushed due to #22402 being closed.

PS Bun feels more stable since the PR was first created!

This PR will resolve #22283 and start of #21075

Jordan-Hall avatar Apr 02 '24 00:04 Jordan-Hall

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview May 22, 2024 2:58pm

vercel[bot] avatar Apr 02 '24 00:04 vercel[bot]

cc: @JamesHenry

Jordan-Hall avatar Apr 02 '24 00:04 Jordan-Hall

I was working in WSL. I'll fix the test in the morning on my Linux laptop

Jordan-Hall avatar Apr 02 '24 02:04 Jordan-Hall

@JamesHenry I think this is all good now. The failed test is due to snapshot changes. Are you happy with me just updating the snapshot?

Jordan-Hall avatar Apr 02 '24 10:04 Jordan-Hall

I am looking at the pruning. Never looked at zig code but it wonder if porting this would help https://github.com/oven-sh/bun/blob/main/src/install/lockfile.zig

Jordan-Hall avatar Apr 03 '24 10:04 Jordan-Hall

@meeroslav happy to follow up with that too. Was thinking of a PR for bun itself but it may need some design consideration (ie inside js for executors or inside a standalone bun plugin.

Jordan-Hall avatar Apr 03 '24 13:04 Jordan-Hall

I am looking at the pruning. Never looked at zig code but it wonder if porting this would help https://github.com/oven-sh/bun/blob/main/src/install/lockfile.zig

Unless they have an npm package that exposes generator as a Node function, we don't want to "reimplement" it within Nx. For the time being, we can use yarn lock file generation and once there is a way for bun to generate a lock file without running the install we'll switch to that.

Something like bun install --lock-file-only or bun install --prune would be perfect.

meeroslav avatar Apr 03 '24 13:04 meeroslav

One thing I noticed when testing locally is that setting local registry in $HOME/.bunfig.toml didn't always work for me unless I run bun install --no-cache. Not sure what the issue it, but perhaps it's related to https://github.com/oven-sh/bun/issues/4901.

This would affect e2e testing because we need to set it to:

// $HOME/.bunfig.toml
[install]
registry = "http://localhost:4873"

jaysoo avatar Apr 03 '24 14:04 jaysoo

One thing I noticed when testing locally is that setting local registry in $HOME/.bunfig.toml didn't always work for me unless I run bun install --no-cache. Not sure what the issue it, but perhaps it's related to https://github.com/oven-sh/bun/issues/4901.

This would affect e2e testing.

jaysoo avatar Apr 03 '24 14:04 jaysoo

@jaysoo one thing I haven't done is update verdaccio to edit bunfig.toml to add a custom registery

Jordan-Hall avatar Apr 03 '24 15:04 Jordan-Hall

One thing I noticed when testing locally is that setting local registry in $HOME/.bunfig.toml didn't always work for me unless I run bun install --no-cache. Not sure what the issue it, but perhaps it's related to oven-sh/bun#4901.

This would affect e2e testing because we need to set it to:

// $HOME/.bunfig.toml
[install]
registry = "http://localhost:4873"

I believe this is by design. When you say it wasn't working what do you mean? By default bun always go to cache as long as the major version is matching

Jordan-Hall avatar Apr 03 '24 18:04 Jordan-Hall

@jaysoo one thing I haven't done is update verdaccio to edit bunfig.toml to add a custom registery

We should do this here or as a follow-up to add bun to nightly tests, since it will be needed there.

I believe this is by design. When you say it wasn't working what do you mean? By default bun always go to cache as long as the major version is matching

I would publish a new version (e.g. 19.0.0) locally, update .bunfig.toml, then run bun install. The install fails due to 19.0.0 not being on npm registry, so I have to pass --no-cache to make it work. Seems like a bug, but it's nothing to do with Nx, we can just always run with --no-cache for e2e tests.

jaysoo avatar Apr 03 '24 18:04 jaysoo

I'll update the test shortly. Is they anything else we need for this or want me to look at?

Jordan-Hall avatar Apr 05 '24 12:04 Jordan-Hall

I'll update the test shortly. Is they anything else we need for this or want me to look at?

I think we're good. When we enable nightlies we'll make sure all the local registry support is there as well.

jaysoo avatar Apr 05 '24 16:04 jaysoo

I'm happy adding that now if you show me where

Jordan-Hall avatar Apr 06 '24 14:04 Jordan-Hall

I'm happy adding that now if you show me where

@Jordan-Hall not need, we'll do that in a separate PR. Let's get this one over the line

meeroslav avatar Apr 08 '24 14:04 meeroslav

@meeroslav any chance you can update that last remaining snapshot for me. Sorry on windows and snapshot changes too much compared to doing it on linux. Not got my linux laptop on me sorry

Jordan-Hall avatar Apr 08 '24 18:04 Jordan-Hall

So latest pr revase broke it again -_- let me know when you want this in / ready and I'll fix it again.

Jordan-Hall avatar Apr 10 '24 00:04 Jordan-Hall

So latest pr revase broke it again -_- let me know when you want this in / ready and I'll fix it again.

Looks like it's green now. I'll do more testing on it, it looked good during my last test. If it's good, we can probably get it in for Nx 19.

jaysoo avatar Apr 16 '24 13:04 jaysoo

So latest pr revase broke it again -_- let me know when you want this in / ready and I'll fix it again.

Looks like it's green now. I'll do more testing on it, it looked good during my last test. If it's good, we can probably get it in for Nx 19.

Thank you. Let me know if you find any issues. Next stop bun executors 😅

Jordan-Hall avatar Apr 16 '24 17:04 Jordan-Hall

Is there an ETA on when this can be merged in and be usable? I'm starting a new React/React Native project for my company this week or next and I really want to use Bun + Nx 👀

If I decided to go with an alternative package manager just to get the project started (like pnpm for example), would it involve significant overhead to switch over to Bun?

enaluz avatar Apr 17 '24 05:04 enaluz

Is there an ETA on when this can be merged in and be usable? I'm starting a new React/React Native project for my company this week or next and I really want to use Bun + Nx 👀

If I decided to go with an alternative package manager just to get the project started (like pnpm for example), would it involve significant overhead to switch over to Bun?

As far as I know, bun cannot change pnpm lockfile to bun lockfile. so I would choose classic npm to start with. (also workspaces in pnpm are a little bit different too)

mehrangta avatar Apr 17 '24 08:04 mehrangta

Pushed one more fix and doing more testing. We're ready to merge Nx 19 features, so we should be merging this very soon.

jaysoo avatar Apr 17 '24 15:04 jaysoo

Quick update on this PR, we are planning to include this in Nx 19.1 rather than 19. The reason is that Nx 19 is a stability release to address some issues around Project Crystal, so we're pushing some new features to Nx 19.1, including Bun.

jaysoo avatar Apr 30 '24 14:04 jaysoo

@jaysoo any update or indication when this will land in 19.1 (beta)?

ItsWendell avatar May 13 '24 08:05 ItsWendell

@jaysoo any update or indication when this will land in 19.1 (beta)?

I think we can merge it soon once green again.

jaysoo avatar May 17 '24 17:05 jaysoo

@Jordan-Hall please complete https://github.com/Jordan-Hall/nx/pull/2/

benpsnyder avatar May 18 '24 20:05 benpsnyder

@Jordan-Hall please complete Jordan-Hall#2

I'll sort it later. I was going to fix this tonight when little one asleep. Sorry didn't get any notification

Jordan-Hall avatar May 18 '24 20:05 Jordan-Hall

@Jordan-Hall please complete Jordan-Hall#2

I think i want @jaysoo view on this. Now that you have added getRegistryUrl. How do you want to do this in bun as it doesnt have the same support

Jordan-Hall avatar May 18 '24 20:05 Jordan-Hall