Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 실시간알림
- 성장기
- 개발자
- SSE
- Node.js기본
- mariadb
- partitioning
- Partition
- 열공하자
- Lag
- node.js
- localStorage
- 파티셔닝
- PostgreSQL
- node.js란
- frontend
- EventSource
- ServerSentEvent
Archives
- Today
- Total
써치킴의 우당탕탕 개발 블로그
[JS Bundler][Ch1][Parcel] babel 본문
babel
ECMAScript 2015(ES6) 이상 버전의 코드를 이전 JavaScript 엔진에서 실행할 수 있는 이전 버전과 호환되는 JavaScript 버전으로 변환하는데 주로 사용되는 무료 오픈 소스 JavaScript 트랜스컴파일러
1. @babel/core 설치
npm i -D @babel/core
2. @babel/preset-env 설치
npm i -D @babel/preset-env
3. 루트 경로에 .babelrc.js 파일 추가
module.exports = {
presets: ['@babel/preset-env']
}
- 이렇게 작성하면, 우리가 앞으로 작성하는 모든 JavaScript는 babel을 통해서 ES5 문법으로 변경되어 브라우저에서 동작할 것이다.
4. package.json에서 borwserslist 옵션 추가
"browserslist": [
"> 1%",
"last 2 versions"
]
- babel도 borwserslist 옵션의 영향을 받아서 JavaScript 문법을 최적화하여 변환
5. async, await(비동기 문법)를 사용하기 위해 @babel/plugin-transform-runtime 설치
npm install -dev @babel/plugin-transform-runtime
6. babelrc.js 파일에 plugins 옵션 추가
module.exports = {
presets: ['@babel/preset-env'],
plugins: [
['@babel/plugin-transform-runtime']
]
}
'파도파도 나오는 JavaScript' 카테고리의 다른 글
[JS Bundler][Ch1][Webpack] 프로젝트 생성 (0) | 2022.02.22 |
---|---|
[JS Bundler][Ch1][Parcel] CLI (0) | 2022.02.21 |
[JS Bundler][Ch1][Parcel] autoprefixer (0) | 2022.02.21 |
[JS Bundler][Ch1][Parcel] 정적 파일 연결 (0) | 2022.02.21 |
[JS Bundler][Ch1][Parcel] 프로젝트 생성 (0) | 2022.02.21 |
Comments