News for hackers. Stuff that matters.
Re:Monorepos in JavaScript and TypeScript by steve_adams_86 on Thursday June 02, 2022 @02:34PM (#31598823)
They mentioned trying to use Yarn workspaces.

I set up several projects in a monorepo recently using Yarn 3, and while the end result was awesome, the path to success was dark and weedy.

It seemed I was constantly 95% of the way there, but some detail or another wasn't quite right. Yarn has no solution for this, because the problem is the integration of tooling. eslint, typescript, prettier, jest, relay, you name it. They each want to work together and integrate with each other in different ways, using various sources of truth, and so on. Then your IDE needs to adhere to the same protocols, but various extensions have different opinions about default configurations.

Along the way you really need to know your tooling deeply, or you're in for some suffering.

Relatively simple projects with full buy-in of Yarn 3's tooling are probably pretty easy. Once you get relatively complex though, I don't know, I don't think any of this is easy.

It does sound like Nx handles a bunch of this stuff for you, which I'd love to try out. I really like that Yarn isn't particularly opinionated though. Once I had things set up, there was very little to change or that could break. The scaffolding was fairly plain to see, easy to work with, and we owned it. With something like Nx where things reportedly "just work", I worry it would be an unsettling blend of black boxes and black magic making my tooling and code work... Until it didn't, at which point I'd wish I used something less opinionated.

Re:Monorepos in JavaScript and TypeScript by kitten_mittens_ on Thursday June 02, 2022 @06:43PM (#31601476)
You might mean with pnp as the node linker? Migrating to yarn 3 from yarn 1 wasn't an issue at all for me with `nodeLinker: node_modules`.

I just wrapped up switching over to pnp though, and that '95% of the way there' line you mentioned rings a bell for me.

Re:Monorepos in JavaScript and TypeScript by steve_adams_86 on Thursday June 02, 2022 @10:31PM (#31603552)
I did try pnp and in some ways it seemed promising, but it wasn’t the right fit for what we wanted at the time.

You’re right, most of it did work using node_modules as the linker, but I found things like having eslint configure itself from typescript inexplicably blew up and resolving those issues wasn’t trivial.

I mean, it was on and off work for a week or so, migrating a few apps and packages (including a react native app, that was a big part of the motivation and struggle in the migration in the first place), so all in all it was acceptable. And the productivity gain was more than worth it. It just wasn’t as trivial as we expected/hoped.