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
feat(typescript): use TypeScript as plugin source code
Also automate release and generally improve and overhaul the setup. release-npm
BREAKING CHANGE: source code switches from JavaScript (with Flow) to TypeScript
This will bootstrap a new plugin inside a folder named `react-native-my-plugin` accordingly. Inside that folder the commands mentioned hereafter are available. The prefix `react-native-` is optional and will be removed where the React Native context is implied.
19
20
20
-
Start working on your plugin by editing `src/index.js` which will be the entry point for the plugin.
21
+
Start working on your plugin by editing `index.tsx` which will be the entry point for the plugin.
21
22
22
23
## App
23
24
@@ -33,7 +34,7 @@ This will create an app inside `/app` where except `/app/App.js` all files are g
33
34
npm run watch
34
35
```
35
36
36
-
Running the above will watch the plugin `/src/` folder for any kind of changesand copy them over to the app which will then automatically hot-reload.
37
+
Running the above will watch the plugin source code for any kind of changes, rebuild and copy over the changes to the app which will then automatically hot-reload.
37
38
38
39
Don't forget to always check your plugin both on Android and iOS even though your not using native code the provided components might still differ depending on the platform.
39
40
@@ -43,11 +44,12 @@ The template is configured to work with Jest out of the box. All non-native func
43
44
44
45
```
45
46
npm test
47
+
npm run test:watch # Keep watching and retesting on changes.
46
48
```
47
49
48
-
## Types
50
+
## TypeScript
49
51
50
-
Since React Native will usually run in a modern JavaScript engine there is no need to transpile your source code and apps can directly use the plugin source code. The Flow type checker is the default type system for react native and the source code is writting in flow. While TypeScript is the more popular type checker overall flow is more popular in the React Native ecosystem and can be used out of the box. Therefore this package will only support flow.
52
+
Flow the type checker native to React Native has largely failed to gain popularity and also lags behind TypeScript in many other important aspects. Since a good chunk of bigger React Native projects are written in TypeScript plugins should provide type definitions.
51
53
52
54
## Troubleshooting
53
55
@@ -57,6 +59,8 @@ If you have issues building the app for iOS try the following
57
59
- Update Cocoapods with `sudo gem install cocoapods`
58
60
- Update Pod dependencies in `app/ios` folder with `pod update`
59
61
62
+
To avoid bundling additional dependencies with `esbuild` mark them as `--external` in the `npm run build` script.
63
+
60
64
## Examples
61
65
62
66
The following plugins have been created with create-react-native-plugin as a starting point.
@@ -65,5 +69,11 @@ The following plugins have been created with create-react-native-plugin as a sta
0 commit comments