강의

멘토링

커뮤니티

Inflearn Community Q&A

2scent's profile image
2scent

asked

Complete Guide to Frontend Build Systems - Part.1: Module System

CJS - Understanding CJS operation with Browserify

캐싱 단계 질문

Resolved

Written on

·

92

·

Edited

1

안녕하세요. 좋은 강의 감사합니다.

캐싱 관련해서 이해가 잘 안 되는 부분이 있어 질문드립니다.

강의에서는 modules[moduleId][0].call의 첫 번째 인자로 module.exports를 넘겨주는 것이 캐싱과 관련 있다고 설명해주셨는데요.

제가 코드를 보기엔 module.exportsthisArg로 전달되긴 하지만, 실질적인 캐싱은 함수 내부에서 세 번째 인자인 module 객체를 직접 수정하면서 (module.exports = { add };) 이뤄지는 것으로 보입니다.

즉, thisArg로 전달된 module.exports는 실제로 의미 있는 쓰임새가 없고, 캐싱은 module.exports를 직접 설정함으로써 발생하는 것 아닌가 싶은데, 혹시 제가 잘못 이해한 걸까요?

javascriptnode.js웹팩viteesm

Answer 1

2

Rafael님의 프로필 이미지
Rafael
Instructor

답변이 늦어서 죄송합니다. 질문자님 지적해주신 부분이 맞습니다. 잘못 설명했네요. module.exports call의 첫번째 는 thisArg 이기 때문에 캐싱과 관련이 없습니다. 실제 캐싱은 module.exports 를 직접 대입함으로써 이뤄집니다. 감사합니다!

2scent님의 프로필 이미지
2scent
Questioner

답변 감사합니다!

2scent's profile image
2scent

asked

Ask a question