- Babel 是什么?
- 使用指南
- 配置 Babel
- Learn ES2015
- 升级到 Babel 7
- 升级到 Babel 7 (API)
- 编辑器
- 插件
- 预设(Presets)
- 附加说明
- FAQ
- Babel 路线图
- Options
- Config Files
- @babel/cli
- @babel/polyfill
- @babel/plugin-transform-runtime
- @babel/register
- @babel/preset-env
- @babel/preset-stage-0
- @babel/preset-stage-1
- @babel/preset-stage-2
- @babel/preset-stage-3
- @babel/preset-flow
- @babel/preset-react
- babel-preset-minify
- @babel/preset-typescript
- @babel/parser
- @babel/core
- @babel/generator
- @babel/code-frame
- @babel/helpers
- @babel/runtime
- @babel/template
- @babel/traverse
- @babel/types
@babel/runtime
@babel/runtime
is a library that contain's Babel modular runtime helpers and a version of regenerator-runtime
.
Installation
npm install --save @babel/runtime
See also:
@babel/runtime-corejs2
.
Usage
This is meant to be used as a runtime dependency
along with the Babel plugin @babel/plugin-transform-runtime
. Please check out the documentation in that package for usage.
Why
Sometimes Babel may inject some code in the output that is the same and thus can be potentially re-used.
For example, with the class transform (without loose mode):
class Circle {}
turns into:
function _classCallCheck(instance, Constructor) {
//...
}
var Circle = function Circle() {
_classCallCheck(this, Circle);
};
this means every file that contains a class would have the _classCallCheck
function repeated each time.
With @babel/plugin-transform-runtime
, it would replace the reference to the function to the @babel/runtime
version.
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
var Circle = function Circle() {
_classCallCheck(this, Circle);
};
@babel/runtime
is just the package that contains the implementations of the functions in a modular way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论