babel-preset-react-app-new 2.0.4 → 2.0.6

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 CHANGED
@@ -1,63 +1,32 @@
1
- # babel-preset-react-app
1
+ # babel-preset-react-app-new
2
2
 
3
- This package includes the Babel preset used by [Create React App](https://github.com/facebook/create-react-app).<br>
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
- - [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) – How to create a new app.
7
- - [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App.
5
+ ---
8
6
 
9
- ## Usage in Create React App Projects
7
+ ## tiger-new 项目中的使用
10
8
 
11
- The easiest way to use this configuration is with [Create React App](https://github.com/facebook/create-react-app), which includes it by default. **You don’t need to install it separately in Create React App projects.**
9
+ 如果你使用的是 **`tiger-new` 脚手架创建的项目**,
10
+ **通常不需要手动安装或配置本 preset**。
12
11
 
13
- ## Usage Outside of Create React App
12
+ `tiger-new` 会在内部自动引入并配置 `babel-preset-react-app-new`。
14
13
 
15
- If you want to use this Babel preset in a project not built with Create React App, you can install it with the following steps.
14
+ ---
16
15
 
17
- First, [install Babel](https://babeljs.io/docs/setup/).
16
+ ## 在非 tiger-new 项目中的使用
18
17
 
19
- Then install babel-preset-react-app-new.
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
- Then create a file named `.babelrc` with following contents in the root folder of your project:
24
+ ### 2. 配置 Babel
26
25
 
27
- ```json
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
- "presets": [["react-app-new", { "flow": true, "typescript": false }]]
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
@@ -69,8 +69,7 @@ module.exports = function (api, opts, env) {
69
69
  return {
70
70
  assumptions: {
71
71
  setPublicClassFields: true,
72
- privateFieldsAsProperties: true,
73
- setPublicClassFields: true
72
+ privateFieldsAsProperties: true
74
73
  },
75
74
  presets: [
76
75
  isEnvTest && [
package/dev.js CHANGED
@@ -9,5 +9,5 @@
9
9
  const create = require('./create');
10
10
 
11
11
  module.exports = function (api, opts) {
12
- return create(api, Object.assign({ helpers: false }, opts), 'development');
12
+ return create(api, Object.assign({ helpers: false }, opts), 'development');
13
13
  };
package/index.js CHANGED
@@ -9,12 +9,12 @@
9
9
  const create = require('./create');
10
10
 
11
11
  module.exports = function (api, opts) {
12
- // This is similar to how `env` works in Babel:
13
- // https://babeljs.io/docs/usage/babelrc/#env-option
14
- // We are not using `env` because it’s ignored in versions > babel-core@6.10.4:
15
- // https://github.com/babel/babel/issues/4539
16
- // https://github.com/facebook/create-react-app/issues/720
17
- // It’s also nice that we can enforce `NODE_ENV` being specified.
18
- const env = process.env.BABEL_ENV || process.env.NODE_ENV;
19
- return create(api, opts, env);
12
+ // This is similar to how `env` works in Babel:
13
+ // https://babeljs.io/docs/usage/babelrc/#env-option
14
+ // We are not using `env` because it’s ignored in versions > babel-core@6.10.4:
15
+ // https://github.com/babel/babel/issues/4539
16
+ // https://github.com/facebook/create-react-app/issues/720
17
+ // It’s also nice that we can enforce `NODE_ENV` being specified.
18
+ const env = process.env.BABEL_ENV || process.env.NODE_ENV || 'development';
19
+ return create(api, opts, env);
20
20
  };
package/package.json CHANGED
@@ -1,16 +1,13 @@
1
1
  {
2
2
  "name": "babel-preset-react-app-new",
3
- "version": "2.0.4",
4
- "description": "Babel preset used by Create React App",
3
+ "version": "2.0.6",
4
+ "description": "Babel preset used by tiger-new",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/facebook/create-react-app.git",
7
+ "url": "git+https://github.com/qiqiboy/tiger-new.git",
8
8
  "directory": "packages/babel-preset-react-app"
9
9
  },
10
10
  "license": "MIT",
11
- "bugs": {
12
- "url": "https://github.com/facebook/create-react-app/issues"
13
- },
14
11
  "files": [
15
12
  "create.js",
16
13
  "dependencies.js",
package/prod.js CHANGED
@@ -9,5 +9,5 @@
9
9
  const create = require('./create');
10
10
 
11
11
  module.exports = function (api, opts) {
12
- return create(api, Object.assign({ helpers: false }, opts), 'production');
12
+ return create(api, Object.assign({ helpers: false }, opts), 'production');
13
13
  };