-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Monorepo support #533
Comments
yes, but probably not for a little while |
Related: The |
can the implementation of workspaces include:
|
I just want to say that I haven't missed |
@factoidforrest yarn has |
Maybe consider monorepo support similar to |
I prefer pnpm |
|
He probably meant to pnpm workspaces. |
Yarn 2+ Plug n Play also has full scope isolation for each package. A main reason the pnpm resolution strategy might be preferable to Plug n Play is because notable projects such as React Native are currently incompatible with Plug n Play. On the flip side, Plug n Play might be considered preferable because it may solve the doppleganger problem differently than pnpm (someone ought to investigate this comparison in detail). Personally I find the "non-single singletons" doppleganger consequence the most important one because it's the root cause behind monorepo bugs involving popular libraries such as graphql-js. Overall though I think Bun should make an authoritative choice for workspaces/monorepo support rather than letting this be highly configurable. Too much configurability leads to too much project complexity both in implementation and from a client's point of view w/ too many options to choose from & too much boilerplate. Bun needs to have a clear story for workspace/monorepos before it can be seriously considered for adoption by medium to large projects. |
Agree. IMO The point I want to make by bring yo For example: |
turborepo is greate. |
It does not. |
Hi, IMHO the only responsibility from Bun regarding workspaces is dependency resolution, the rest should be handled by a monorepo tool like Turbo or NX. |
Is Related to previous comments: #533 (comment), #533 (comment) |
Per #83 it looks like some support for |
Probably, related: #2517 |
Speed and disk space are the reasons pnpm is best for monorepos. Whenever multiple workspaces within a monorepo depend on the same npm package, npm and yarn download and install a separate copy of the npm package for each workspace, whereas pnpm symbolically links them all to the same download of the package. Yarn's PnP does muddy the waters a bit, but its problems keep me from using it. See the benchmarks. |
For yarn, it's configurable: https://yarnpkg.com/configuration/yarnrc#nmMode |
Will migrate to bun when this works |
I am not sure now, it isn't supported and described here? https://bun.sh/docs/install/workspaces Do I miss something or can this issue be closed as completed? EDIT: I see it miss support for script execution inside monorepo, ex. |
@Hebilicious Thank you very much for the excellent overview! I am still of the opinion that documented basic use cases should work. So, the binary answer to this issue is "yes, a monorepo is supported". I am not opposed to leaving this issue open, but, in my opinion, it distracts from addressing actual problems. Alternatively, @wbcs could add your list to the top of this issue, making it a meta-issue for outstanding work. |
I feel it's relevant to share this tweet that I saw from Jarred a couple of months ago. He mentioned wanting to have another go at implementing workspaces as he didn't think the support was that good, although I'm not sure if they ever got around to redoing it. |
Additionally plugging this issue: #4844 |
It's hard to argue that bun has monorepo support in terms of a drop in replacement for pnpm. Replacing pnpm works for the most part, but as soon as you come to monorepos (which is very common in OSS and other projects these days), you have to redesign your whole CI/CD pipelines or have challenges that can be very hard to solve. |
@itpropro I think (1) "doesn't fail when used in a monorepo", (2) "supports monorepos", and (3) "includes tools that make working with monorepos easy" are all valid but very different definitions of "monorepo support". Bun currently meets the criteria for (1), sort of meets the criteria for (2), but definitely does not meet the criteria for (3). As evidenced by @Hebilicious's list (#533 (comment)) and other comments here, there's a lot of work to do before that last criteria is met. Documentation should probably reflect that. |
Criteria 1 is not met yet, Bun 1.0 still fails for me when adding packages as described in #3502. |
@Hebilicious thanks for the follow up. A hybrid approach is interesting and could work. It just seems that it might be hard to evangelize across a development team. An errant |
Currently I have to use
would be nice to see someone given a mandate to go implement this. |
I'm a bit new to the front end world but is this what y'all are talking about? |
Found I can use bun workspaces, but when i build a package i have to execute the build with node, because bun is hoisting all dependencies to root level node_modules, and only node will be able to find those from a /packages/package1/build/app.js by properly checking parent directories in module resolution. Bun seem to only check inside the package which is not where bun install puts the node_module. |
@81reap as I mentioned in my comment and as is mentioned in those workspaces docs, Bun does hoisting but that is an inadequate way to support monorepos because it permits/encourages the phantom dependencies bug class. |
With pnpm I sometimes have to set i.e. shamefully-hoist=true in the .npmrc, but that taps into another highly upvoted issue |
Any updates on this? Confirmed monorepos not working still as of bun v1.1.4 on any OS |
@metaspartan This whole issue is huge and there's definitely work being done. No need to put more pressure on this great group of people doing the hard work. |
It looks like the features to support monorepos are getting close to being ready. Any ETA or an RC build that includes these features? |
Everything merged to the |
When i try switch npm to bun in windows I hoping to see if monorepo will be there . Hope that bunjs make it simple and easy like |
Nothing stops anyone from using third party monorepo tools with bun. The contributors at oven/bun are doing a great work, let's not turn this issue into a long discussion with lots of people just asking for the same thing they are already working on. Progress will be reported when it is relevant, as every open source project do, and bun hasn't let us down. |
@wesleycoder I think a lot of us are just excited. We would like to simplify our install, unit-testing, browser testing, build, and runner down to a single tool. So no anxiety needed. I did some refactoring of my codebase and the amount of packages I was able to rip out of my projects when using bun was just... chef's kiss. That is until I realized the monorepo support and specificity that I got with tools like pnpm was just not there due to hoisting (the node_modules strategy that bun currently uses). Another part of what has some of us excited is that installing, building, testing, running with bun would cut down on compute time and result in real cost savings for production apps. |
With latest bun I was able to finally migrate from pnpm to bun workspaces (have 4 packages that rely on one another), without any of the issues with hoisting i mentioned prior - thanks! |
what happens if you update the packages? does the |
It's been 2 months since i migrated from pnpm to bun workspaces, and my experience is unfortunately that pnpm still is far superior to bun workspaces in some important ways. The killer feature(s) that I find is sorely missing and hope will land soon is: Bun needs a way to do recursive interactive |
@birkskyum I agree 💯. This comment on #1223 issue suggests using Taze. I've had good luck with that as an intermediate solution. It will detect & use the appropriate package manager. For my bun monorepo it is successfully using
|
@gitblit , that worked surprisingly well, thanks! With a third-party solution there, I guess a plaintext lockfile is all i need. Especially the text lockfile is important for CI tools like renovate/dependabot to avoid conflicts all over the place, and to be able to inspect diffs. I don't think that dependabot even works for regular repos with bun yet though, and it's not clear to me if support for regular repos will also bring support for monorepos - we'll see i guess: |
So long as bun continues to hoist packages up to This is the ONLY issue preventing me from using Have there been any developments with bun's handling of monorepos that prevent hoisting? |
Why?! Can you elaborate? |
TL;DR Hoisting breaks module boundaries. Hoisting of dependencies enables any module managed in a monorepo to access any dependency installed by another module. Deliberately or accidentally leveraging these "ghost dependencies" can lead to unexpected failures when bundling, running code in CI/CD, or deployment. Breaking of module boundaries is such a common source of errors that most monorepo tools have aligned on explicit declarations of dependencies and deliberate separation of dependencies per module. |
I know talk is cheap. Here is a minimum reproduction repository for the issues being discussed. https://github.com/hansoksendahl/min-repro-bun-ws-hoist |
I just wanted to hopefully add some weight to this conversation. Here at Motion I put in a ton of effort to try and migrate from yarn to bun for installs, but the hoisting issue(s) prevented us from migrating. React Native operates best with its deps living at the same location as the app in a monorepo, and we could find a clean migration path without the ability to limit hoisting. I really want to continue to push to use bun across our stack, but this issue continues to not get support in favor of other newer features. I'm starting to lose Hope that bun is focused on the correct stuff, especially as it relates to supporting larger companies wanting to use bun. |
@Scalahansolo we will fix it |
I concur with the general hoisting conversation here, though there is also an existing issue where |
Updated issue
Bun supports
"workspaces"
in package.json,"workspace:*
(protocol) in dependencies, and many more features related to workspaces. See the docs page on workspaces.You can also use
bun run --filter="*/*lib"
to run multiple package.json scripts from different packages within a workspace simultaneously and view tail the logs - see the docs.We're keeping this issue open for now, but it's not entirely clear what's left to close it.
Original issue below
What is the problem this feature will solve?
bun not support monorepo(root package.json
workspaces
field,workspace:*
schema, etc.)What is the feature you are proposing to solve the problem?
The download speed of monorepo will be faster
What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: