batijs / bati

Next-gen scaffolder. Get started with fully-functional apps, and choose any tool you want.
https://batijs.dev
MIT License
196 stars 11 forks source link

Support modern yarn #291

Open JosXa opened 4 days ago

JosXa commented 4 days ago

Since there's already this awesome graphical user interface, it would be really cool if I could pick Yarn 4.3+ over pnpm (as I use it everywhere).

Fun fact: pnpm uses huge chunks of the yarn berry code base under the hood ^^

magne4000 commented 4 days ago

I haven't really used yarn since 1.0, could you direct me to what's different to current yarn usage (i.e. yarn dlx @batijs/cli)?

JosXa commented 4 days ago

Yarn Berry (v2+) has very little resemblance to legacy Yarn. It supports workspaces, automatic constraints, package patching, and their own Plug'n'Play linker, though that's still experimental and I wouldn't recommend enabling it for the masses (see nodeLinker setting below). They keep on innovating and it's become an amazing tool, arguably the most powerful one of the available choices.

The right way to grab the latest yarn install is to first corepack enable (node 18+), then yarn set version latest. This will generate a .yarnrc file, update the gitignore, and prepare the project for yarn install (or just yarn).

I'd recommend the following .yarnrc settings:

compressionLevel: mixed
enableGlobalCache: true
nodeLinker: node-modules

supportedArchitectures:
  cpu:
    - x64
    - arm64
  libc:
    - glibc
    - musl
  os:
    - darwin
    - linux
    - win32

yarnPath: .yarn/releases/yarn-<whatever-is-latest-version>.cjs

The result could then be checked into the generator.

magne4000 commented 4 days ago

I'm still not sure to understand what's not working currently if you execute yarn dlx @batijs/cli