Buble.js 开源项目使用教程
buble项目地址:https://gitcode.com/gh_mirrors/bu/buble
1. 项目的目录结构及介绍
buble/
├── bin/
│ └── buble.js
├── dist/
│ ├── buble.js
│ └── buble.min.js
├── src/
│ ├── ast.js
│ ├── compiler.js
│ ├── index.js
│ ├── transforms/
│ │ ├── arrow.js
│ │ ├── classes.js
│ │ ├── default-param.js
│ │ ├── destructuring.js
│ │ ├── for-of.js
│ │ ├── modules.js
│ │ ├── spread.js
│ │ └── template-literals.js
│ └── utils.js
├── test/
│ ├── fixtures/
│ ├── helpers.js
│ └── index.js
├── .babelrc
├── .editorconfig
├── .eslintrc
├── .gitignore
├── .npmignore
├── .travis.yml
├── LICENSE
├── package.json
├── README.md
└── yarn.lock
目录结构介绍
bin/
: 包含可执行文件。dist/
: 包含编译后的文件。src/
: 包含源代码文件。ast.js
: 抽象语法树相关代码。compiler.js
: 编译器核心代码。index.js
: 入口文件。transforms/
: 包含各种转换器代码。
test/
: 包含测试文件。.babelrc
: Babel 配置文件。.editorconfig
: 编辑器配置文件。.eslintrc
: ESLint 配置文件。.gitignore
: Git 忽略文件配置。.npmignore
: npm 忽略文件配置。.travis.yml
: Travis CI 配置文件。LICENSE
: 许可证文件。package.json
: 项目依赖和脚本配置。README.md
: 项目说明文档。yarn.lock
: Yarn 锁定文件。
2. 项目的启动文件介绍
项目的启动文件位于 bin/
目录下的 buble.js
。这个文件是 Buble.js 的命令行入口,负责解析命令行参数并调用相应的功能。
#!/usr/bin/env node
const buble = require('../dist/buble.js');
const fs = require('fs');
const path = require('path');
// 命令行参数解析和功能调用
3. 项目的配置文件介绍
.babelrc
Babel 配置文件,用于指定 Babel 的转换规则和插件。
{
"presets": ["es2015"],
"plugins": ["transform-runtime"]
}
.eslintrc
ESLint 配置文件,用于指定代码风格和检查规则。
{
"extends": "eslint:recommended",
"rules": {
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single"],
"semi": ["error", "always"]
}
}
package.json
项目依赖和脚本配置文件。
{
"name": "buble",
"version": "0.19.8",
"description": "The blazing fast, batteries-included ES2015 compiler",
"main": "dist/buble.js",
"bin": {
"buble": "bin/buble.js"
},
"scripts": {
"build": "rollup -c",
"prepublish": "npm run build",
"test": "mocha"
},
"dependencies": {
"acorn": "^5.7.3",
"magic-string": "^0.25.1",
"minimist": "^1.2.0",
"source-map": "^0.6.1"
},
"devDependencies": {
"chai": "^4.1.2",
"eslint": "^4.19.1",
"mocha": "^5.2.