chenhuiYj / chenhuiYj/note

babel 的简介

Open
#25 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
6
Forks
0
PR merge metrics
No merged PRs in 30d

Description

笔记摘录文章:前端工程师的自我修养-关于 Babel 那些事儿

1.什么是babel

直接点说就是, Babel 是一个 JavaScript 编译器,用于将 ECMAScript 2015+(ES6) 版本的代码转换为向下兼容的 JavaScript(ES5) 语法,以便能够运行在当前版本和旧版本的浏览器或其他环境中。

2.babel的原理

babel的工作原理的核心就是 AST (抽象语法树)。先将ECMAScript 2015+(ES6) 版本源码转成抽象语法树,然后对语法树进行处理,生成新的语法树,最后根据新语法树生成新的 JavaScript(ES5) 代码,整个编译过程可以分为 3 个阶段 parsing (解析)、transforming (转换)、generating (生成)。

image

Babel 只负责编译新标准引入的新语法,比如 Arrow function、Class、ES Module 等,它不会编译原生对象新引入的方法和 API,比如 Array.includes,Map,Set 等,这些需要通过 Polyfill(polyfill 的翻译过来就是垫片,垫片就是垫平不同浏览器环境的差异) 来解决

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue body is the only available source and names no file, entry point, or test. Start by locating where repository notes about Babel belong, then determine whether this Chinese introduction should be added or revised; done should be a clear, placed documentation entry with the requested Babel overview.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.