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
).
The script doesn't work with legacy decorators, here's what it picked up from the non-decorated filesInteractionManager 1AsyncStorage 3
NativeModules 1
Platform 7
Dimensions 5
View 3
Animated 4
Easing 1
BackAndroid 1
PixelRatio 1
With decorators working (thanks @ lelandrichardson!):
I have some abstractions over the Animated API, feel like these numbers don't show my appreciation for the API