๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๊ฐœ๋ฐœ

yarn berry, zero install

 

 

๐Ÿ“ yarn์€ ๊ธฐ์กด์˜ npm์ด ๊ฐ€์ง€๊ณ  ์žˆ๋˜ ๋ฌธ์ œ์ ๋“ค์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ๋“ฑ์žฅํ–ˆ๋‹ค.

 

 

๐Ÿ“ pnp (Plug n Play)

Yarn ์ตœ์‹  ๋ฆด๋ฆฌ์ฆˆ์˜ ๊ธฐ๋ณธ ์„ค์น˜ ์ „๋žต์ด๋‹ค. ์‹ค์ œ๋กœ plugin์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. yarn์„ ์›ํ•˜๋Š”๋Œ€๋กœ ํ™•์žฅํ•  ์ˆ˜ ์žˆ๋‹ค.

๊ธฐ์กด์˜ ๋ฌด๊ฑฐ์› ๋˜ node_modules ๋Œ€์‹ , ํŒจํ‚ค์ง€๋“ค์— ๋Œ€ํ•œ ์ •๋ณด๋Š” .zip ํŒŒ์ผ๋กœ ์••์ถ•ํ•˜์—ฌ .yarn/cache ํด๋”์— ์ €์žฅํ•˜๊ณ  ์ด๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•œ ์ •๋ณด๋ฅผ .pnp.cjs (๋˜๋Š” .pnp.js) ํŒŒ์ผ์— ๊ธฐ๋กํ•œ๋‹ค.

์ค‘๋ณต ์„ค์น˜๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ  ์œ ๋ น ์˜์กด์„ฑ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•œ๋‹ค.

 


๐Ÿ“ Zero Install

npm ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๋กœ๋ถ€ํ„ฐ ๋ชจ๋“ˆ์„ ์„ค์น˜ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ์ตœ์ดˆ .yarn/cache์— zip ํ˜•ํƒœ๋กœ ๋ณด๊ด€ํ•˜์—ฌ ์ €์žฅ์†Œ์— ๊ฐ™์ด push ํ•˜๋Š” ํ˜•ํƒœ์ด๋‹ค. ๊นƒ์— ๊ฐ™์ด ์˜ฌ๋ฆฌ๊ธฐ ๋•Œ๋ฌธ์— ๋‹จ์ ๋„ ์žˆ์ง€๋งŒ git pull ํ•˜๋Š” ์ˆœ๊ฐ„, ์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋œ ๊ฒƒ๊ณผ ๋‹ค๋ฆ„ ์—†๋‹ค.

yarn berry๋ฅผ ํ†ตํ•ด ๋งŒ๋“  ์˜์กด์„ฑ ํด๋”๋Š” ํฌ๊ธฐ๊ฐ€ ์ž‘๊ธฐ ๋•Œ๋ฌธ์— git clone ์ดํ›„ ๋ณ„๋„์˜ ์„ค์น˜ ๊ณผ์ •์„ ์ƒ๋žตํ•œ ๋’ค ๋ฐ”๋กœ ์‚ฌ์šฉํ•˜๋Š” zero install์„ ์‹œ๋„ํ•  ์ˆ˜ ์žˆ๋‹ค.

zero install์„ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ git clone์ด ๋๋‚˜์ž๋งˆ์ž ๋ฐ”๋กœ ๋นŒ๋“œ๊ฐ€ ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐฐํฌ๊นŒ์ง€์˜ ์†๋„๋ฅผ ๊ฐ์†Œ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.

https://yarnpkg.com/features/caching#zero-installs

 

Cache strategies | Yarn

How to ensure your installs perform the absolute minimal amount of work.

yarnpkg.com

 


๐Ÿ“ ์ฐธ๊ณ 

https://toss.tech/article/node-modules-and-yarn-berry

 

node_modules๋กœ๋ถ€ํ„ฐ ์šฐ๋ฆฌ๋ฅผ ๊ตฌ์›ํ•ด ์ค„ Yarn Berry

ํ† ์Šค ํ”„๋ก ํŠธ์—”๋“œ ๋ ˆํฌ์ง€ํ† ๋ฆฌ ๋Œ€๋ถ€๋ถ„์—์„œ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ € Yarn Berry. ์ฑ„ํƒํ•˜๊ฒŒ ๋œ ๋ฐฐ๊ฒฝ๊ณผ ์‚ฌ์šฉํ•˜๋ฉด์„œ ์ข‹์•˜๋˜ ์ ์„ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค.

toss.tech

 

 

๐Ÿ“ ๋ช…๋ น์–ด

$ npm install -g yarn
$ yarn --version

$ npx create-react-app yarn-berry-app --template typescript

// node_modules์™€ package.lock.json ์ง€์šฐ๊ธฐ

$ yarn set version berry
$ yarn install

 

 

๐Ÿ“ ํด๋” ๊ตฌ์„ฑ

.git, .yarn, public, src

.gitignore, .pnp.cjs, README.md, yarn.lock, .pnp.loader.mjs, package.json, tsconfig.json, .yarnrc.yml

 

 

 

์›๋ž˜ ๊ทธ๋ƒฅ git pull ์ดํ›„์— npm install์„ ์ž๋™์œผ๋กœ ๋˜๊ฒŒ ํ•˜๊ณ  ์‹ถ์–ด์„œ ์ฐพ์•„๋ณด๊ธฐ ์‹œ์ž‘ํ•œ๊ฑด๋ฐ...

์ผ๋‹จ ์ด๋Ÿฐ ๊ธ€๋„ ์žˆ๋‹ค.

https://dev.to/zirkelc/automatically-install-npm-dependencies-on-git-pull-bg0

 

Automatically Install NPM Dependencies on Git Pull

UPDATE: I released a npm package for this script: git-pull-run. Please report any issues or...

dev.to

 

๊ทธ๋ฆฌ๊ณ  ์‘์šฉํ•ด๋ณผ๋งŒํ•œ hook๋„ ์žˆ๋‹ค. post-merge

https://git-scm.com/docs/githooks#_post_merge

 

Git - githooks Documentation

Hooks are programs you can place in a hooks directory to trigger actions at certain points in gitโ€™s execution. Hooks that donโ€™t have the executable bit set are ignored. By default the hooks directory is $GIT_DIR/hooks, but that can be changed via the c

git-scm.com

 

Husky๋ฅผ ์‚ฌ์šฉํ•ด์„œ ํ•ด๋ณด๋ฉด ๋  ๊ฒƒ ๊ฐ™๋‹ค

.husky ํด๋” ์•ˆ์— post-merge ๋ผ๋Š” ํŒŒ์ผ๋ช…์œผ๋กœ ์ €์žฅ

zsh์—ฌ์„œ bash์˜ ๊ฒฝ์šฐ ๋ณ€๊ฒฝ์ด ํ•„์š”ํ•  ์ˆ˜๋„ ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค.

#!/bin/zsh
. "$(dirname "$0")/_/husky.sh"

IFS=$'\n'
# regex supports mono-repos with a package.json at root-level and at package-level
PACKAGE_LOCK_REGEX="(^packages\/.*\/package-lock\.json)|(^package-lock\.json)"
# extract all paths to package-lock.json files 
PACKAGES=("$(git diff --name-only HEAD@{1} HEAD | grep -E "$PACKAGE_LOCK_REGEX")")

if [[ ${PACKAGES[@]} ]]; then
  for package in $PACKAGES; do
    echo "๐Ÿ“ฆ $package was changed. Running npm install to update your dependencies..."
    DIR=$(dirname package)
    cd "$DIR" && npm install
  done
fi

 

 

 

++ ์–ด์จŒ๋“  ์ด ๊ธ€ ์ฃผ์ œ๋Š” yarn berry๋‹ˆ๊นŒ...!

https://haranglog.tistory.com/28

 

Yarn berry์—์„œ React + Jest + Cypress + TypeScript + Github Actions CI/CD๋ฅผ ์„ธํŒ…ํ•ด๋ณด์ž

์ด ๊ธ€์€ Yarn berry package manager๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ React ํ”„๋กœ์ ํŠธ์—์„œ ์ดˆ๊ธฐ ์„ธํŒ…ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋‹ค๋ฃจ๊ณ  ์žˆ์œผ๋ฉฐ, ์—ฌ๋Ÿฌ ์‹œํ–‰์ฐฉ์˜ค๋ฅผ ๊ฒช์–ด๊ฐ€๋ฉฐ ๊ฒฝํ—˜ํ•œ ๊ฒƒ๋“ค์„ ํ† ๋Œ€๋กœ ์ž‘์„ฑํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค.๐Ÿ˜‰ ์ด ๊ธ€์˜ ๋ชฉ์ ์€ ๊ฒช์—ˆ๋˜

haranglog.tistory.com

์ด๋ฆ„๋“ค๋งŒ ๋ด๋„ ํž™ํ•˜๋‹ค ใ…Žใ…Žใ…Ž