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
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,15 @@ The CLI can build code for following targets:
9
9
- Generic CommonJS build
10
10
- ES modules build for bundlers such as webpack
11
11
- Flow definitions (copies .js files to .flow files)
12
+
- TypeScript definitions (uses tsc to generate declaration files)
12
13
13
14
## Why?
14
15
15
16
Metro handles compiling source code for React Native libraries, but it's possible to use them in other targets such as web. Currently, to handle this, we need to have multiple babel configs and write a long `babel-cli` command in our `package.json`. We also need to keep the configs in sync between our projects.
16
17
17
18
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.
18
19
19
-
Bob wraps tools such as `babel-cli` and simplifies these common tasks across multiple projects. It's tailored specifically to React Native projects to minimize the configuration required.
20
+
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.
20
21
21
22
## Installation
22
23
@@ -40,7 +41,8 @@ To configure your project manually, follow these steps:
40
41
"output": "lib",
41
42
"targets": [
42
43
["commonjs", {"flow": true}],
43
-
"module"
44
+
"module",
45
+
"typescript",
44
46
]
45
47
}
46
48
```
@@ -59,6 +61,7 @@ To configure your project manually, follow these steps:
59
61
"main": "lib/commonjs/index.js",
60
62
"module": "lib/module/index.js",
61
63
"react-native": "src/index.js",
64
+
"typescript": "lib/typescript/src/index.d.ts",
62
65
"files": [
63
66
"lib/",
64
67
"src/"
@@ -74,10 +77,6 @@ To configure your project manually, follow these steps:
0 commit comments