To run this, you will first need to install the following npm packages:
npm i babylon babylon-walk glob
Then, with the script in the current directory in find-rn-imports.js
, you would want to run it, passing in
a glob pattern to hit all of the source code files in your repo. For instance I ran something like:
node ./find-rn-imports.js '!(node_modules|test)/**/*.js'
The output of that script will indicate which react native APIs you are importing and how many times in your
code base (though this assumes you are using import
and not require
).
name count
View 129
TouchableWithoutFeedback 7
Image 9
PixelRatio 46
NativeModules 11
Vibration 2
TouchableOpacity 16
StyleSheet 114
PanResponder 5
Animated 6
Easing 4
Text 8
ListView 9
Dimensions 22
Keyboard 8
Platform 16
StatusBar 3
InteractionManager 2
Modal 1
ScrollView 16
Linking 7
ActivityIndicator 4
Switch 1
TextInput 1
Clipboard 6
TouchableHighlight 2
AppState 2
Navigator 1
Alert 1
AlertIOS 1
PushNotificationIOS 2
BackAndroid 2
RefreshControl 2
WebView 4
findNodeHandle 1
Picker 3
Share 1
AsyncStorage 1
ActionSheetIOS 1