๋ฐ˜์‘ํ˜•

๐Ÿ€ 1. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑํ•˜๊ธฐ

  • yarn ์„ค์น˜
npm install -g yarn
  • Create React App ๊ธฐ๋ฐ˜ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ
yarn create react-app wedding --template typescript

๐Ÿ€ 2. Yarn Berry(PnP) ์„ค์ •

  1. node_modules ํด๋” ์‚ญ์ œ
  2. berry ๋ฒ„์ „ ์„ค์ • ::  yarn set version berry
    yarn set version berry
  3. root ๊ฒฝ๋กœ์— .yarnrc.ymlํŒŒ์ผ ์ƒ์„ฑ
    //.yarnrc.yml ํŒŒ์ผ์— pnp ์„ค์ •ํ•˜๊ธฐ (node_modules ๋Œ€์‹  pnp๋ฐฉ์‹ ์‚ฌ์šฉ!)
    nodeLinker: pnp
    
  4. yarn install
    yarn install
    

ํ™•์žฅ ํ”„๋กœ๊ทธ๋žจ ZipFS ์„ค์น˜


Yarn Berry์—์„œ TypeScript๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ zipfs ํ™•์žฅ ๊ธฐ๋Šฅ์ด ํ•„์š”ํ•œ ์ด์œ ๋Š” Yarn์˜ Plug'n'Play(PnP) ๋ฐฉ์‹ ๋•Œ๋ฌธ์ด๋‹ค. Yarn Berry๋Š” node_modules ํด๋” ์—†์ด .zip ํŒŒ์ผ์„ ํ†ตํ•ด ์˜์กด์„ฑ์„ ๊ด€๋ฆฌํ•˜๋Š”๋ฐ, ์ด๋•Œ ํŒŒ์ผ ์‹œ์Šคํ…œ์„ .zip ํ˜•์‹์œผ๋กœ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ค๋Š” ๊ณผ์ •์—์„œ zipfs๊ฐ€ ํ•„์š”ํ•˜๋‹ค.๋”ฐ๋ผ์„œ zipfs๋ฅผ ์„ค์น˜ํ•˜๋ฉด, Yarn Berry์˜ PnP ๋ฐฉ์‹๊ณผ TypeScript ํ™˜๊ฒฝ ๊ฐ„์˜ ํ˜ธํ™˜์„ฑ์„ ๋†’์—ฌ์ค€๋‹ค. zipfs ํ™•์žฅ ๊ธฐ๋Šฅ์€ .zip ํŒŒ์ผ๋กœ ์ €์žฅ๋œ ํŒจํ‚ค์ง€๋“ค์„ ํŒŒ์ผ ์‹œ์Šคํ…œ์ฒ˜๋Ÿผ ์ฝ์„ ์ˆ˜ ์žˆ๋„๋ก ์ง€์›ํ•˜์—ฌ, PnP ํ™˜๊ฒฝ์—์„œ TypeScript๋‚˜ ๊ธฐํƒ€ ํˆด์ด ์ •์ƒ์ ์œผ๋กœ ํŒจํ‚ค์ง€ ํŒŒ์ผ์„ ํƒ์ƒ‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•œ๋‹ค.

 

6. Yarn Berry์˜ Plug'n'Play(PnP) ๋ฐฉ์‹๊ณผ VSCode์˜ ํ†ตํ•ฉ ์„ค์ •

yarn dlx @yarnpkg/sdks vscode
๐Ÿ”ฅ๐Ÿ‘ฟ ์ฃผ์˜!!
๋ช…๋ น ํŒ”๋ ˆํŠธ(Ctrl+Shift+P)๋ฅผ ์—ด๊ณ  TypeScript: Restart TS Server"๋ฅผ ์„ ํƒ → "Use Workspace Version”๋ถ€๋ชจ ํด๋”๊ฐ€ ์•„๋‹Œ ํ”„๋กœ์ ํŠธ ํด๋” ์ž์ฒด์—์„œ VSCode๋ฅผ ์—ด์–ด์•ผ ํ•œ๋‹ค!!!! vscode๊ฐ€ ๋ถ€๋ชจํด๋”๋กœ ์—ด๋ ค์žˆ๋‹ค๋ฉด Use Workspace Version๊ฐ€ ๋ณด์ด์ง€ ์•Š์Œ...
์ฐธ๊ณ :: https://github.com/yarnpkg/berry/issues/4788

๐Ÿ€ 3. typescript ์„ค์ •

์›Œํฌ์ŠคํŽ˜์ด์Šค ๋ฒ„์ „์— ๋งž๋Š” ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๋„๋ก ํ—ˆ์šฉํ•ด์ฃผ๊ธฐ

๐Ÿ€ 4. .gitignore์— ์ถ”๊ฐ€

# yarn zero install
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# ์ฐธ๊ณ ::  https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored

 

Questions & Answers | Yarn

A list of answers to commonly asked questions.

yarnpkg.com

 

๐Ÿ€ 5. App.test.tsx์˜ ํƒ€์ž…์—๋Ÿฌ ์ œ๊ฑฐํ•˜๊ธฐ

ํƒ€์ž…์—๋Ÿฌ ์™•์ฐฝ

yarn remove @testing-library/jest-dom
yarn add -D @types/testing-library__jest-dom @testing-library/jest-dom

๐Ÿ€ 6. yarn start!!!!!!!!!!!!!!!!!!!!!!!

yarn start

 

๋ฐ˜์‘ํ˜•

+ Recent posts