We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TS 常用 tsc 编译。如果抛开类型检查和生成 d.ts ,babel编译也是可以的。
TS
tsc
d.ts
babel
Parser
transform
Generator
Emitter
sourcemap
es
@babel/preset-env
@babel/proposal-xx
polyfill
core-js
The text was updated successfully, but these errors were encountered:
No branches or pull requests
TS
常用tsc
编译。如果抛开类型检查和生成d.ts
,babel
编译也是可以的。tsc 编译过程
babel 编译过程
总结:tsc vs babel
相同点:
babel
和tsc
的编译流程大同小异,都有把源码转换成 AST 的Parser
和 AST 的transform
,最后都会用Generator
(或Emitter
)把 AST 转换生成目标代码和sourcemap
。区别:
babel
不做类型检查,也不会生成d.ts
文件;tsc
都支持。tsc
支持最新的es
标准特性和部分草案的特性;babel
通过@babel/preset-env
支持所有标准特性,也可以通过@babel/proposal-xx
来支持各种非标准特性,支持的语言特性上babel
更强一些。tsc
没有做polyfill
的处理,需要全量引入core-js
,而babel
的@babel/preset-env
会根据 targets 的配置按需引入core-js
。tsc
是整个项目一起编译,babel
是每个文件单独编译。The text was updated successfully, but these errors were encountered: