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
์ด๋ฆ๋ค๋ง ๋ด๋ ํํ๋ค ใ ใ ใ