You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+77-2Lines changed: 77 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,11 @@
6
6
7
7
The CLI can build code for following targets:
8
8
9
-
- Android AAR files
10
9
- Generic CommonJS build
11
10
- ES modules build for bundlers such as webpack
12
11
- Flow definitions (copies .js files to .flow files)
13
-
- TypeScript definitions (uses tsc to generate declaration files)
12
+
- TypeScript definitions (uses `tsc` to generate declaration files)
13
+
- Android AAR files
14
14
15
15
## Why?
16
16
@@ -72,6 +72,12 @@ To configure your project manually, follow these steps:
72
72
]
73
73
```
74
74
75
+
Make sure to change specify correct files according to the targets you have enabled.
76
+
77
+
It's usually good to point to your source code with the `react-native` field to make debugging easier. Metro already supports compiling a lot of new syntaxes including JSX, Flow and TypeScript and it will use this field if present.
78
+
79
+
If you're building TypeScript definition files, also make sure that the `types` field points to a correct path. Depending on the project configuration, the path can be different for you than the example snippet.
80
+
75
81
1. Add the output directory to `.gitignore` and `.eslintignore`
76
82
77
83
```gitignore
@@ -87,6 +93,75 @@ To configure your project manually, follow these steps:
87
93
88
94
And we're done 🎉
89
95
96
+
## Options
97
+
98
+
The options can be specified in the `package.json` file under the `@react-native-community/bob` property, or in a `bob.config.js` file in your project directory.
99
+
100
+
### `source`
101
+
102
+
The name of the folder with the source code which should be compiled. The folder should include an `index` file.
103
+
104
+
### `output`
105
+
106
+
The name of the folder where the compiled files should be output to. It will contain separate folder for each target.
107
+
108
+
### `targets`
109
+
110
+
Various targets to build for. The available targets are:
111
+
112
+
#### `commonjs`
113
+
114
+
Enable compiling source files with Babel and use commonjs module system.
115
+
116
+
This is useful for running the code in Node (SSR, tests etc.). The output file should be referenced in the `main` field of `package.json`.
117
+
118
+
By default, this will compile the code for last 2 versions of modern browsers, as well as JSX. It'll also strip TypeScript and Flow annotations. To customize the babel config used, you can pass the [`configFile`](https://babeljs.io/docs/en/options#configfile) or [`babelrc`](https://babeljs.io/docs/en/options#babelrc) options.
119
+
120
+
If your source code is written in [Flow](http://www.typescriptlang.org/), You can also specify the `copyFlow` option to copy the source files as `.js.flow` to the output folder. If the `main` entry in `package.json` points to the `index` file in the output folder, the flow type checker will pick these files up to use for type definitions.
Enable compiling source files with Babel and use ES module system. This is essentially same as the `commonjs` target and accepts the same options, but leaves the `import`/`export` statements in your code.
131
+
132
+
This is useful for bundlers which understand ES modules and can tree-shake. The output file should be referenced in the `module` field of `package.json`.
Enable generating type definitions with `tsc` if your source code is written in [TypeScript](http://www.typescriptlang.org/).
143
+
144
+
By default, it'll use the `tsconfig.json` file in your project root. If you want to use a different config, you can specify it using the `project` option.
Enable assembling Android AAR files for a library for React Native modules including native code.
155
+
156
+
It's also possible to convert the AAR with the `reverseJetify` option to use the [Android support Library](https://developer.android.com/topic/libraries/support-library) using the [`jetifier`](https://www.npmjs.com/package/jetifier) package if your package is using [AndroidX](https://developer.android.com/jetpack/androidx). This is useful to publish packages for older projects which haven't migrated to AndroidX.
157
+
158
+
You can also specify the `androidPath` (defaults to `android`) to specify the `android` directory and `androidBundleName` (defaults to `android.aar`) to customize the name of AAR file.
0 commit comments