open-index/open-npm huggingface dataset:
npm package: @hammal/babel-preset-app
Description: Babel preset for hammal-cli-service
Author: NZ
Latest version: 0.14.0

# @hammal/babel-preset-app

## 上手

### 安装

```
npm i --save-dev @hammal/babel-preset-app
```

### 配置 `.babelrc`

```
{
  "presets": [
    "@hammal/babel-preset-app"
  ]
}
```

### 选项

默认值：`{ react: false, debug: false }`

#### react

支持编译 react 的 `jsx` 代码：

```
{
  "presets": [
    ["@hammal/babel-preset-app", {"react": true}]
  ]
}
```

`react` 选项设置为 `true` 时，会自动检测目标项目下是否安装了 `react-hot-loader` 依赖，并配置 `react-hot-loader/babel` 到插件选项中。

#### debug

开启 `@babel/preset-env` 的 `debug`。根据 [browserslist](https://github.com/browserslist/browserslist)  配置，在编译时输出导入的 corejs 模块信息。参考文档：[babel-preset-env](https://babeljs.io/docs/en/babel-preset-env#debug)

```
{
  "presets": [
    ["@hammal/babel-preset-app", {"debug": true}]
  ]
}
```

## ENV

需要配置环境变量 `NODE_ENV` 或者 `BABEL_ENV`。变量值必须为：`development`、`production`，或者 `test`。

如需要在 npm-scripts 中配置，建议安装 [cross-env](https://www.npmjs.com/package/cross-env)：

```
npm i --save-dev cross-env
```

## 内置的 presets 和 plugins

### presets

[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env)

[@babel/preset-react](https://babeljs.io/docs/en/babel-preset-react)

### plugins

[@babel/plugin-proposal-nullish-coalescing-operator](https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator)

[@babel/plugin-proposal-optional-chaining](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining)

[@babel/plugin-proposal-decorators](https://babeljs.io/docs/en/babel-plugin-proposal-decorators)

[@babel/plugin-proposal-class-properties](https://babeljs.io/docs/en/babel-plugin-proposal-class-properties)

[@babel/plugin-transform-runtime](https://babeljs.io/docs/en/babel-plugin-transform-runtime)

## [Polyfill](https://babeljs.io/docs/en/babel-polyfill)

需要手动在项目入口顶部导入 `core-js/stable` 和 `regenerator-runtime/runtime`。该 preset 中，已包含这 2 个模块，可直接导入。

```js
import 'core-js/stable';
import 'regenerator-runtime/runtime';
```

### 调试

**在以 `npm link ` 的方式调试时需要独立安装**。

考虑到对项目的完整编译和浏览器适配，`preset-env` 的 `useBuiltIns` 选项暂时使用了 `entry`。`usage` 固然很好，可按需导入 corejs，但会忽略安装在 `node_modules` 下的第三方模块的 ES6+ 的 api 适配。

## [Runtime](https://babeljs.io/docs/en/babel-runtime)

默认已开启，且已包含 `@babel/runtime` 依赖。但未开启 `corejs` 选项，否则会完全转换 ES6+ 的所有 API 为沙盒模式，而不是根据 browserslist，这会导致代码冗余。

## License

[MIT](https://github.com/nicolaszhao/hammal/blob/master/LICENSE) © [nicolaszhao](https://github.com/nicolaszhao)
npm package: @hammal/cli
Description: Hammal boilerplate generator based on Command-line interface
Author: NZ
Latest version: 0.15.2

# @hammal/cli

## Install

```shell
npm install -g @hammal/cli
```

## Usage

```
Usage: hammal <command>

Options:
  -v, --version                              output the version number
  -h, --help                                 output usage information

Commands:
  create <project-name>                      generate a new project from a template
  list|ls                                    list available templates
  add <template> <repository> [description]  add one custom template
  del <template>                             delete one custom template
```

## Templates

```
pure --------- nicolaszhao/pure-boilerplate
react -------- nicolaszhao/react-boilerplate
react-spa ---- nicolaszhao/react-spa-boilerplate
react-app ---- nicolaszhao/react-app-boilerplate
vue-app ------ nicolaszhao/vue-app-boilerplate
library ------ nicolaszhao/library-boilerplate
react-library  nicolaszhao/react-library-boilerplate
```

You can add custom templates locally.

## @hammal/cli-service projects

`pure`, `react`, `react-spa`, `react-app`.

## browserslist

All projects will set [browserslist](https://github.com/browserslist/browserslist) config in `package.json`:

```
{
  ...
  "browserslist": {
    "production": [
      "> 1%",
      "last 2 versions"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
```

## ESLint

All templates have ESLint, you can remove ESLint by terminal inquirer.

## License

[MIT](https://github.com/nicolaszhao/hammal/blob/master/LICENSE) © [nicolaszhao](https://github.com/nicolaszhao)