babel
바벨은 JS 컴파일러다. ES2015+ 코드를 내가 명시한 타겟 브라우저에 맞게 변경해준다.
이제 create-tmon-webapp에 포함된 바벨 설정을 보자.
@babel/core
babel config 파일을 이용하여 실제로 transpile을 진행.
@babel/preset-env
주의할 점은 stage-x 플러그인을 지원하지 않는다!!
preset, plugin? plugin은 특정 syntax에 대한 것이다. @babel/plugin-transform-arrow-functions preset은 plugin들의 모음집. stage별로 (stage-X) 혹은 react, typescript와 같은 것들을 transpile 하기 위한 모음집들.
@babel/preset-react
react 관련 코드를 변형하기 위한 프리셋. 대표적으로 jsx -> React.createElement
@babel/plugin-transform-runtime
코드 사이즈를 절약하기 위해 바벨에서 주입해준 helper 함수 재사용해도록 도와주는 플러그인. (inline babel hleper -> @babel/runtime/helper 모듈 대신 사용.)
그래서 @babel/runtime을 dependency로 포함해야한다.
global scope 오염을 피하기 위해 사용
core-js
잘 알려진 @babel/polyfill은 core-js와 regenerator-runtime을 import한다.
Last updated
Was this helpful?