Search
๐ŸŽฌ

Firebase Functions Typescript hot reload

์ƒ์„ฑ์ผ
2022/02/20 07:35
ํƒœ๊ทธ
Flutter
์†์„ฑ

Hot reload

๊ฐœ๋ฐœ ๊ณผ์ •์—์„œ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ–ˆ์„ ๋•Œ ๋ฐ”๋กœ ์›น ์‚ฌ์ดํŠธ์— ๋ฐ˜์˜ํ•˜์—ฌ ์ˆ˜์ •๊ฒฐ๊ณผ๋ฅผ ๋น ๋ฅด๊ฒŒ ๋ณผ ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ.
๋น„์Šทํ•œ ๊ฐœ๋…์œผ๋กœ cold reload๊ฐ€ ์žˆ๋Š”๋ฐ, ์ด๋Š” ์†Œ์Šค์ฝ”๋“œ ์ˆ˜์ • ํ›„ ํ”„๋กœ๊ทธ๋žจ์„ ์žฌ์‹œ์ž‘ ํ•ด์•ผ ๋ณ€๊ฒฝ ๋‚ด์šฉ์ด ๋ฐ˜์˜๋œ๋‹ค.
hot reload๋Š” ๊ฐœ๋ฐœ ์†๋„์— ํฐ ์˜ํ–ฅ์„ ๋ฏธ์นœ๋‹ค.

Firebase Functions + Typescript

Typescript๋Š” build ๊ณผ์ •์ด ํ•„์š”ํ•˜๋‹ค. ๋”ฐ๋ผ์„œ Firebase Functions ๊ธฐ๋Šฅ์„ Typescript๋กœ ๊ฐœ๋ฐœํ•  ๋•Œ Hot reload ๋ฅผ ์ง€์›ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ €์žฅ โ†’ build โ†’ mount ์˜ ๊ณผ์ •์ด ํ•„์š”ํ•˜๋‹ค.
google, stack overflow ์— ๋‹ค์–‘ํ•œ ๊ตฌํ˜„๋ฐฉ๋ฒ•์ด ์žˆ์ง€๋งŒ firebase ์˜ ๋ฒ„์ „์ด ์ตœ์‹ ํ™” ๋๊ธฐ ๋•Œ๋ฌธ์ธ์ง€ ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜๋Š” ๊ฒฐ๊ณผ๋ฌผ์„ ์ฐพ๊ธฐ ํž˜๋“ค์—ˆ๋‹ค.

๊ฒฐ๋ก 

functions ๋””๋ ‰ํ† ๋ฆฌ์˜ package.json ํŒŒ์ผ์„ ์ˆ˜์ •ํ•œ๋‹ค

AS-IS

"scripts": { ..., "serve": "npm run build && firebase emulators:start --only functions", ... }
JSON
๋ณต์‚ฌ

TO-BE

"scripts": { ..., "serve": "tsc -w | firebase emulators:start --only functions", ... }
JSON
๋ณต์‚ฌ
functions ๋‚ด๋ถ€ ํŒŒ์ผ์˜ ์ˆ˜์ •๋˜์—ˆ์„ ๋•Œ functions์— ๋ฐ”๋กœ ๋ฐ˜์˜๋จ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.