Skip to content

Commit 5751252

Browse files
committed
docs: improve how options are documented
1 parent 9b4957f commit 5751252

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ yarn add --dev react-native-builder-bob
7070
"source": "src",
7171
"output": "lib",
7272
"targets": [
73-
["aar", {"reverseJetify": true}],
7473
["commonjs", {"copyFlow": true}],
7574
"module",
7675
"typescript",
@@ -144,16 +143,20 @@ Enable compiling source files with Babel and use commonjs module system.
144143

145144
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`.
146145

147-
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. You can customize the environments to compile for by using a [browserslist config](https://github.com/browserslist/browserslist#config-file). 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.
146+
By default, the code is compiled to support last 2 versions of modern browsers. It also strips TypeScript and Flow annotations, and compiles JSX. You can customize the environments to compile for by using a [browserslist config](https://github.com/browserslist/browserslist#config-file).
148147

149-
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.
148+
In addition, the following options are supported:
150149

151-
By default, sourcemaps are generated alongside the compiled files. You can disable them by setting the `sourceMaps` option to `false`.
150+
- `configFile` & `babelrc` (`boolean`): To customize the babel config used, you can pass the [`configFile`](https://babeljs.io/docs/en/options#configfile) option as `true` if you have a `babel.config.js` or [`babelrc`](https://babeljs.io/docs/en/options#babelrc) option if you have a `.babelrc`. This may break the default configuration, so use these options only if you know what you're doing.
151+
152+
- `copyFlow` (`boolean`): If your source code is written in [Flow](http://www.typescriptlang.org/), You can 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.
153+
154+
- `sourceMaps` (`boolean`): Sourcemaps are generated by default alongside the compiled files. You can disable them by setting the `sourceMaps` option to `false`.
152155

153156
Example:
154157

155158
```json
156-
["commonjs", { "babelrc": true, "copyFlow": true }]
159+
["commonjs", { "configFile": true, "copyFlow": true }]
157160
```
158161

159162
##### `module`
@@ -165,14 +168,18 @@ This is useful for bundlers which understand ES modules and can tree-shake. The
165168
Example:
166169

167170
```json
168-
["module", { "babelrc": true, "copyFlow": true }]
171+
["module", { "configFile": true }]
169172
```
170173

171174
##### `typescript`
172175

173176
Enable generating type definitions with `tsc` if your source code is written in [TypeScript](http://www.typescriptlang.org/).
174177

175-
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. Furthermore, the tsc binary will be resolved to ./node_modules/.bin/tsc. Use the `tsc` option to specify a different path.
178+
The following options are supported:
179+
180+
- `project` (`string`): By default, the `tsconfig.json` file in the root of your project is used to generate the type definitions. You can specify a path to a different config by using the `project` option. This can be useful if you need to use different configs for development and production.
181+
182+
- `tsc` (`string`): The path to the `tsc` binary is automatically detected and defaults to the one installed in your project. You can use the `tsc` option to specify a different path.
176183

177184
Example:
178185

@@ -184,9 +191,14 @@ Example:
184191

185192
Enable assembling Android AAR files for a library for React Native modules including native code.
186193

187-
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.
194+
The following options are supported:
195+
196+
- `reverseJetify` (`boolean`): If your package is using [AndroidX](https://developer.android.com/jetpack/androidx), it's 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. This is useful to publish packages for older projects which haven't migrated to AndroidX.
197+
198+
- `androidPath` (`string`): You can specify a custom path to the `android` directory if it's not in the default location (`android` in the root of your project).
199+
200+
- `androidBundleName`: By default, the generated `aar` file is named as `android.aar`. You can specify a custom name using this option.
188201

189-
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.
190202
Example:
191203

192204
```json
@@ -215,16 +227,6 @@ This builds the project according to the configuration. This is usually run as p
215227
}
216228
```
217229

218-
#### `run`
219-
220-
This runs a script either with `npm` or `yarn` depending on the command that was used to run `bob`. If the script doesn't exist under the `scripts` section in `package.json`, then it's forwarded to `npm` or `yarn`. This is useful for using inside `package.json` scripts to avoid coupling them with a specific package manager.
221-
222-
```json
223-
"scripts": {
224-
"bootstrap": "bob run install && bob run --cwd example pods"
225-
}
226-
```
227-
228230
## FAQ
229231

230232
### Why should I compile my project with `react-native-builder-bob`?

0 commit comments

Comments
 (0)