# @darcytech/babel-preset-darcytech

> 专为 react app 提供的 Babel preset

Latest version **3.9.0** (published 2024-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @darcytech/babel-preset-darcytech
pnpm add @darcytech/babel-preset-darcytech
yarn add @darcytech/babel-preset-darcytech
bun add @darcytech/babel-preset-darcytech
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.9.0 |
| Published | 2024-12-10 |
| First published | 2022-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 13.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | noshower |
| Keywords | Babel, preset, react, typescript |

## Links

- npm: https://www.npmjs.com/package/@darcytech/babel-preset-darcytech
- npm.io page: https://npm.io/package/@darcytech/babel-preset-darcytech

## Dependencies (7)

- [@babel/core](https://npm.io/package/@babel/core.md) ^7.26.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.26.0
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.26.3
- [@babel/runtime-corejs3](https://npm.io/package/@babel/runtime-corejs3.md) ^7.26.0
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.26.0
- [@babel/plugin-transform-runtime](https://npm.io/package/@babel/plugin-transform-runtime.md) ^7.25.9
- [@babel/plugin-proposal-decorators](https://npm.io/package/@babel/plugin-proposal-decorators.md) ^7.25.9

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 3.9.0 (latest) — 2024-12-10
- 3.8.0 — 2024-08-12
- 3.7.0 — 2024-07-29
- 3.6.2 — 2023-11-28
- 3.6.1 — 2022-11-18
- 3.6.0 — 2022-11-11
- 3.5.2 — 2022-11-10
- 3.5.1 — 2022-09-20
- 3.5.0 — 2022-09-20

## README

# `@darcytech/babel-preset-darcytech`

# 简介

这个 package 是专为 react 应用设计的 babel 预设。

# 安装

```sh
npm install --save-dev @darcytech/babel-preset-darcytech
```

# 用法

## 配置选项

| 选项          | 含义                                                                            | 默认值     |
| ------------- |-------------------------------------------------------------------------------|---------|
| useTypeScript | 是否使用 TypeScript                                                               | true    |
| runtime       | 编译 JSX 使用哪个运行时, React17 推荐使用 automatic (babel7.9.0 开始支持), 旧版 react 使用 classic | classic |
| useBuiltIn   | 该选项配置 @babel/preset-env 如何处理polyfills                                         | entry   |

## 默认使用

```json
// .babelrc
{
  "presets": ["@darcytech/darcytech"]
}
```

## 不使用 Typescript

```json
// .babelrc
{
  "presets": [["@darcytech/darcytech", { "useTypeScript": false }]]
}
```

# 最佳实践

### 使用.browserslistrc 文件指定目标环境

```bash
# Browsers that we support

defaults
not IE 11
```

### 为不同运行环境，指定环境变量

开发环境：

```sh
process.env.BABEL_ENV = "development";
process.env.NODE_ENV = "development";
```

生产环境：

```sh
process.env.BABEL_ENV = "production";
process.env.NODE_ENV = "production";
```

有助于减少线上包的大小。

# 特点

- 支持按需引入 polyfill
- 不污染全局环境
- 支持 React
- 默认支持 TypeScript
- 支持动态导入
- 支持装饰器
- 支持大部分 Javascript 标准

# 支持的语言特性

支持最新的 JavaScript 标准。除了 ES6 语法功能外，它还支持：

- ES2021（例如：Promise.any）
- ES2020（例如：Promise.allSettled、可选链操作符）
- ES2019（例如：Array.prototype.flat）
- ES2018（例如：Rest 参数和扩展运算符）
- ES2017（例如：Object.entries）
- ES2016（例如：Array.prototype.includes）
- ES2015
- 支持 Class 的私有字段、私有方法、静态字段

# 注意

- 不支持 Proxy, 不支持 BigInt
- 不提供 polyfill , 需要自己安装 core-js, 并在项目入口文件引入

---
_Source: https://npm.io/package/@darcytech/babel-preset-darcytech · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
