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
👷♂️ Simple CLI to scaffold and build React Native libraries for different targets.
8
+
👷♂️ Simple set of CLIs to scaffold and build React Native libraries for different targets.
9
9
10
-
## Features
10
+
## Scaffold React Native libraries
11
11
12
-
### Scaffold new projects
13
-
14
-
If you want to create your own React Native module, scaffolding the project can be a daunting task. Bob can scaffold a new project for you with the following things:
12
+
If you want to create your own React Native module, scaffolding the project can be a daunting task. `create-react-native-library` can scaffold a new project for you with the following things:
15
13
16
14
- Simple example modules for Android and iOS which you can build upon
17
15
-[Kotlin](https://kotlinlang.org/) configured for building the module on Android
18
16
- C++ support for native modules on Android and iOS
19
17
-[Expo](https://expo.io/) support for libraries without native code and web support
20
18
- Example React Native app to manually test your modules
21
19
-[ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/), [Husky](https://github.com/typicode/husky) and [Release It](https://github.com/release-it/release-it) pre-configured
22
-
-Bob pre-configured to compile your files
20
+
-`react-native-builder-bob` pre-configured to compile your files
23
21
-[CircleCI](https://circleci.com/) pre-configured to run tests on the CI
This will ask you few questions about your project and generate a new project in a folder named `react-native-awesome-module`.
48
30
49
-
The difference from [create-react-native-module](https://github.com/brodybits/create-react-native-module) is that the generated project with Bob is very opinionated and configured with additional tools.
The difference from [create-react-native-module](https://github.com/brodybits/create-react-native-module) is that the generated project with `create-react-native-library` is very opinionated and configured with additional tools.
34
+
35
+
## Build your React Native libraries
36
+
37
+
`react-native-builder-bob` can build code in your React Native library for following targets:
50
38
51
-
### Configuring an existing project
39
+
- Generic CommonJS build
40
+
- ES modules build for bundlers such as webpack
41
+
- Flow definitions (copies .js files to .flow files)
42
+
- TypeScript definitions (uses `tsc` to generate declaration files)
43
+
- Android AAR files
52
44
53
-
####Automatic configuration
45
+
### Automatic configuration
54
46
55
-
To automatically configure your project to use Bob, open a Terminal and run:
47
+
To automatically configure your project to use `react-native-builder-bob`, open a Terminal and run:
56
48
57
49
```js
58
50
npx react-native-builder-bob init
59
51
```
60
52
61
-
####Manual configuration
53
+
### Manual configuration
62
54
63
55
To configure your project manually, follow these steps:
64
56
65
-
1. First, install Bob in your project. Open a Terminal in your project, and run:
57
+
1. First, install `react-native-builder-bob` in your project. Open a Terminal in your project, and run:
66
58
67
59
```sh
68
60
yarn add --dev react-native-builder-bob
@@ -127,23 +119,23 @@ To configure your project manually, follow these steps:
127
119
128
120
And we're done 🎉
129
121
130
-
## Options
122
+
###Options
131
123
132
124
The options can be specified in the `package.json` file under the `react-native-builder-bob` property, or in a `bob.config.js` file in your project directory.
133
125
134
-
### `source`
126
+
####`source`
135
127
136
128
The name of the folder with the source code which should be compiled. The folder should include an `index` file.
137
129
138
-
### `output`
130
+
####`output`
139
131
140
132
The name of the folder where the compiled files should be output to. It will contain separate folder for each target.
141
133
142
-
### `targets`
134
+
####`targets`
143
135
144
136
Various targets to build for. The available targets are:
145
137
146
-
#### `commonjs`
138
+
#####`commonjs`
147
139
148
140
Enable compiling source files with Babel and use commonjs module system.
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.
165
157
@@ -171,7 +163,7 @@ Example:
171
163
["module", { "babelrc": true, "copyFlow": true }]
172
164
```
173
165
174
-
#### `typescript`
166
+
#####`typescript`
175
167
176
168
Enable generating type definitions with `tsc` if your source code is written in [TypeScript](http://www.typescriptlang.org/).
Enable assembling Android AAR files for a library for React Native modules including native code.
189
181
@@ -198,7 +190,7 @@ Example:
198
190
199
191
## FAQ
200
192
201
-
### Why should I compile my project with Bob?
193
+
### Why should I compile my project with `react-native-builder-bob`?
202
194
203
195
We write our library code in non-standard syntaxes such as JSX, TypeScript etc. as well as proposed syntaxes which aren't part of the standard yet. This means that our code needs to be compiled to be able to run on JavaScript engines.
204
196
@@ -208,7 +200,7 @@ Currently, to handle such multiple targets, we need to have multiple babel confi
208
200
209
201
Just as an example, this is a command we have in one of the packages: `babel --extensions '.js,.ts,.tsx' --no-babelrc --config-file=./babel.config.publish.js src --ignore '**/__tests__/**' --copy-files --source-maps --delete-dir-on-start --out-dir dist && del-cli 'dist/**/__tests__' && yarn tsc --emitDeclarationOnly`. This isn't all, there's even a separate `babel.config.publish.js` file. And this only works for webpack and Metro, and will fail on Node due to ESM usage.
210
202
211
-
Bob wraps tools such as `babel` and `typescript` to simplify these common tasks across multiple projects. It's tailored specifically to React Native projects to minimize the configuration required.
203
+
`react-native-builder-bob` wraps tools such as `babel` and `typescript` to simplify these common tasks across multiple projects. It's tailored specifically to React Native projects to minimize the configuration required.
212
204
213
205
### How do I add a react-native library containing native code as a dependency in my library?
0 commit comments