react-deep-dive-example icon indicating copy to clipboard operation
react-deep-dive-example copied to clipboard

[문의] p.536 내용문의

Open supersfel opened this issue 1 year ago • 1 comments

안녕하세요! 책 잘보고 있습니다.

module : 모듈 시스템을 설정한다. .... esnext는 import를 사용하므로 import를 사용할 수 있는 환경에서는 esnext를 사용하는 것이 좋다.

moduleResolution : 모듈을 해석하는 방식을 설정한다. node는 node_moudles를 기준으로 모듈을 해석하고 classic은 tsconfig.json이 있는 디렉터리를 기준으로 모듈을 해석한다. node는 module이 CommonJS일때만 사용할수있다.

로 되어있는데 책의 tsconfig.json파일 [p.533]을 보면

{
  "module" : "esnext",
  "moduleResolution" :"node"
}

로 되어있네요 이런 경우 어떻게 동작하게 되나요? moduleResolution:"node"가 무시되나요?

supersfel avatar Feb 02 '24 06:02 supersfel

안녕하세요. 개인사정으로 인해 답이 매우 늦었습니다 죄송합니다 (ㅠㅠ)

먼저 두 속성에 대해서 명확히 설명드려야 할 것 같습니다.

  • module: UMD, CommonJS, AMD, System, ESNext, 등 작성자분께서도 아시는 모듈 시스템을 어떤식으로 가져갈지를 의미합니다. https://www.typescriptlang.org/tsconfig/#module
  • moduleResolution: node_modules 이나 상대경로등 모듈을 찾아가는 방식을 결정합니다.

이에 대한 자세한 내용은

https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution-is-host-defined

에 나와있는데요. 정확히는

this is the counterpart of --module nodenext and is set by default with that module setting.

nodenext일때는 nodenext가 되어 무시되는 것이 맞습니다.

동작 자체는 하는 설정입니다만, @supersfel 님이 지적하신대로 이건 오해의 소지가 있을 것 같아서, 코드를 확인해보고 삭제 내지는 수정 검토해보도록 하겠습니다.

좋은 말씀 해주셔서 감사하고, 다시한번 답이 늦어서 죄송합니다 (ㅠㅠ)

yceffort avatar May 04 '24 05:05 yceffort