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
).
I got
name count
View 98
Text 87
Linking 4
TouchableOpacity 46
Alert 5
Animated 18
ListView 3
StyleSheet 88
TextInput 8
TouchableWithoutFeedback 6
PanResponder 2
AppRegistry 1
Image 32
ScrollView 35
Dimensions 5
TouchableHighlight 6
LayoutAnimation 7
ActivityIndicator 32
Platform 29
ToastAndroid 2
TouchableNativeFeedback 1
BackAndroid 2
PermissionsAndroid 1
AlertIOS 1
Picker 1
AsyncStorage 2
InteractionManager 10
KeyboardAvoidingView 2
RecyclerViewBackedScrollView 2
Modal 3
Keyboard 1
WebView 1
Slider 1
StatusBar 2
AppState 1
NetInfo 1
Navigator 1