babel-preset-react-app-new 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -45
- package/create.js +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,63 +1,32 @@
|
|
|
1
|
-
# babel-preset-react-app
|
|
1
|
+
# babel-preset-react-app-new
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Please refer to its documentation:
|
|
3
|
+
`babel-preset-react-app-new` 是从官方的 [`babel-preset-react-app`](https://github.com/facebook/create-react-app/tree/main/packages/babel-preset-react-app) **fork** 而来的 Babel 预设配置。它主要用于 `tiger-new` 及其相关生态,或作为独立项目的通用 React Babel 预设。
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
- [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App.
|
|
5
|
+
---
|
|
8
6
|
|
|
9
|
-
##
|
|
7
|
+
## 在 tiger-new 项目中的使用
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
如果你使用的是 **`tiger-new` 脚手架创建的项目**,
|
|
10
|
+
**通常不需要手动安装或配置本 preset**。
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
`tiger-new` 会在内部自动引入并配置 `babel-preset-react-app-new`。
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
---
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
## 在非 tiger-new 项目中的使用
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
### 1. 安装 preset
|
|
20
19
|
|
|
21
20
|
```sh
|
|
22
|
-
npm install babel-preset-react-app-new --save-dev
|
|
21
|
+
$ npm install babel-preset-react-app-new --save-dev
|
|
23
22
|
```
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
### 2. 配置 Babel
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
"presets": ["react-app-new"]
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
This preset uses the `useBuiltIns` option with [transform-object-rest-spread](https://babeljs.io/docs/plugins/transform-object-rest-spread/) and [transform-react-jsx](https://babeljs.io/docs/plugins/transform-react-jsx/), which assumes that `Object.assign` is available or polyfilled.
|
|
34
|
-
|
|
35
|
-
## Usage with Flow
|
|
36
|
-
|
|
37
|
-
Make sure you have a `.flowconfig` file at the root directory. You can also use the `flow` option on `.babelrc`:
|
|
26
|
+
在你的 Babel 配置文件(如 `.babelrc` 或 `babel.config.js`)中,添加 `babel-preset-react-app-new` 作为预设:
|
|
38
27
|
|
|
39
28
|
```json
|
|
40
29
|
{
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Usage with TypeScript
|
|
46
|
-
|
|
47
|
-
Make sure you have a `tsconfig.json` file at the root directory. You can also use the `typescript` option on `.babelrc`:
|
|
48
|
-
|
|
49
|
-
```json
|
|
50
|
-
{
|
|
51
|
-
"presets": [["react-app-new", { "flow": false, "typescript": true }]]
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Absolute Runtime Paths
|
|
56
|
-
|
|
57
|
-
Absolute paths are enabled by default for imports. To use relative paths instead, set the `absoluteRuntime` option in `.babelrc` to `false`:
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
{
|
|
61
|
-
"presets": [["react-app-new", { "absoluteRuntime": false }]]
|
|
30
|
+
"presets": ["react-app-new"]
|
|
62
31
|
}
|
|
63
32
|
```
|
package/create.js
CHANGED
|
@@ -114,7 +114,6 @@ module.exports = function (api, opts, env) {
|
|
|
114
114
|
plugins: [
|
|
115
115
|
[require('@babel/plugin-proposal-decorators').default, { legacy: true }],
|
|
116
116
|
[require('@babel/plugin-transform-class-properties').default],
|
|
117
|
-
[require('@babel/plugin-transform-private-methods').default],
|
|
118
117
|
// Polyfills the runtime needed for async/await, generators, and friends
|
|
119
118
|
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
|
|
120
119
|
[
|