두 트랜스컴파일러를 모두 사용해 봤는데, 둘 다 기능이 충실하고 사용하기 쉬웠습니다. 이 책
에서는 트랜스컴파일러로 바벨을 사용합니다. 이제 시작합시다.
바벨은
ES5
를
ES6
로 바꾸는 트랜스컴파일러로 시작했고, 프로젝트가 성장하면서
ES6
와 리
액트
React
,
ES7
등 여러 가지를 지원하는 범용 트랜스컴파일러가 됐습니다. 바벨 버전
6
부터는
ES5
를
ES6
로 변환하려면
ES6
변환 프리셋을 설치하고 바벨이 해당 프리셋을 사용하게끔 설
정해야 합니다. 어떤 프로젝트에서는
ES6
를, 어떤 프로젝트에서는 리액트를 쓰게 될 수도 있
으므로 이번 설정은 이 프로젝트에만 적용되게 만들 겁니다. 먼저
ES6
프리셋을 설치합니다.
$ npm install --save-dev babel-preset-es2015
프로젝트 루트에
.
babelrc
파일을 만듭니다(파일 이름 없이 확장자만 쓰면 숨긴 파일이 됩니
다). 이 파일의 내용은 다음과 같습니다.
{ "
presets
": ["
es2015
"] }
이 파일이 있으면 프로젝트에서 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.