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
).
If you thought the numbers might be bigger... it's because most of our code actually doesn't pull in RN directly, but instead is using components from our UI component library! (these counts do include imports from inside the component library though)