Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel 原理 #46

Open
juzhiyuan opened this issue Jul 9, 2018 · 0 comments
Open

babel 原理 #46

juzhiyuan opened this issue Jul 9, 2018 · 0 comments

Comments

@juzhiyuan
Copy link
Owner

juzhiyuan commented Jul 9, 2018

  1. 分析代码
  2. 生成抽象语法树 AST
  3. 递归遍历 AST 并进行转译并生产新的 AST
  4. 通过 AST 生成成旧语法或兼容性较高的语法

注意:

  • babel 只是转译新标准引入的语法,比如 ES6 的箭头函数转译成 ES5 的函数
  • 新标准引入的新的原生对象、部分原生对象新增的原型方法、新增的API等(如Proxy、Set等),这些babel是不会转译的,需要用户自行引入polyfill来解决
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant