网页 综合 更新时间 2026-11-13 17:18:42

What is Babel? · Babel

自动蜘蛛 babeljs.io 正文约 1940 字
Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments. Here are the main things Babel can do for you:
For an awesome tutorial on compilers, check out the-super-tiny-compiler, which also explains how Babel itself works on a high level.
Babel has support for the latest version of JavaScript through syntax transformers.
These plugins allow you to use new syntax, right now without waiting for browser support. Check out our usage guide to get started.
Babel can convert JSX syntax! Check out our React preset to get started. Use it together with the babel-sublime package to bring syntax highlighting to a whole new level.
You can install this preset with
and add @babel/preset-react to your Babel configuration.
Learn more about JSX
Babel can strip out type annotations! Check out either our Flow preset or TypeScript preset to get started. Keep in mind that Babel doesn't do type checking; you'll still have to install and use Flow or TypeScript to check types.
You can install the flow preset with
or the typescript preset with
Learn more about Flow and TypeScript!
Babel is built out of plugins. Compose your own transformation pipeline using existing plugins or write your own. Easily use a set of plugins by using or creating a preset.
Create a plugin on the fly with astexplorer.net or use generator-babel-plugin to generate a plugin template.
Source map support so you can debug your compiled code with ease.
Babel tries to stay true to the ECMAScript standard, as much as reasonably possible. It may also have specific options to be more spec compliant as a tradeoff to performance.
Babel tries using the least amount of code possible with no dependence on a bulky runtime.
This may be difficult to do in cases, and there are "assumptions" options that tradeoff spec compliancy for readability, file size, and speed.
访问原文 返回搜索 https://babeljs.io/docs
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。