|
| 1 | +# Native API imports survey data |
| 2 | + |
| 3 | +This directory contains data about imported native APIs for the most depended-upon NPM packages |
| 4 | +with native modules, along with the script used to generate/update the API data. The intention is |
| 5 | +to use this data to track and prioritize NAPI coverage of the most-used native APIs. |
| 6 | + |
| 7 | +## TopPackagesWithNativeModules.csv |
| 8 | +This data is somewhat collected using the [`npm-pkg-top`](https://github.com/nodejitsu/npm-pkg-top) |
| 9 | +tool, but manually edited to remove false positives. `npm-pkg-top` does not do a perfect job of |
| 10 | +listing only packages with native modules: when querying with type 'binary' (the default) it |
| 11 | +actually includes any packages that have a preinstall, install, or postinstall script. (It uses the |
| 12 | +[skimdb needBuild view](https://github.com/nodejitsu/npm-pkg-top/blob/master/index.js#L20), which |
| 13 | +[filters packages on the existence of those scripts](https://github.com/npm/npm-registry-couchapp/blob/master/registry/views.js#L263).) |
| 14 | +While `node_gyp` is probably the most common reason for a package to have an install script, there |
| 15 | +are many packages that have other kinds of install scripts. |
| 16 | + |
| 17 | +## TopNativeImports.csv |
| 18 | +This data is collected using the `list-native-imports.js` script in this directory. |
| 19 | + |
| 20 | +The current data includes 31 of the top packages having native modules, by number of dependencies. |
| 21 | +Not included are several top packages that failed to install: fsevents, pty.js, newrelic, mdns, |
| 22 | +java, i2c, windows.foundation, usb, time, v8-profiler, i2c-bus, mapnik, oracledb, grpc |
| 23 | + |
| 24 | +<table> |
| 25 | +<tr><th>Column</th><th>Description</th></tr> |
| 26 | +<tr><td>Pkg count</td><td> |
| 27 | +The number of packages that imported this native API. (A count of the package names in the next |
| 28 | +column.) |
| 29 | +</td></tr> |
| 30 | +<tr><td>Package names</td><td> |
| 31 | +List of packages (NPM package IDs) that imported this native API. |
| 32 | +</td></tr> |
| 33 | +<tr><td>Imported name</td><td> |
| 34 | +Simple name of the native API, including namespace if applicable.<p/> |
| 35 | +This column may contain duplicates when there are multiple APIs (overloads) with the same name. |
| 36 | +</td></tr> |
| 37 | +<tr><td>Imported signature</td><td> |
| 38 | +Full C++ signature of the native API, for C++ imports. For C imports (such as libuv APIs), this is |
| 39 | +just the same as the previous column because C APIs are exported and imported as simple names.<p/> |
| 40 | +Note only 64-bit modules are counted. When a signature includes `__ptr64`, assume that the |
| 41 | +equivalent 32-bit API is imported by a 32-bit build of the same module. |
| 42 | +</td></tr> |
| 43 | +</table> |
| 44 | + |
| 45 | +### Sorting & filtering |
| 46 | +By default the data is sorted by the **Pkg count** column, based on the assumption that APIs |
| 47 | +imported by the most packages are the highest priority. |
| 48 | + |
| 49 | +To filter the view to see only native APIs imported by a single package, use the following steps: |
| 50 | + 1. Open the CSV file in Excel. |
| 51 | + 2. Select the first (header) row and turn on filtering for the headers: |
| 52 | + **Ctrl+Shift+L**, or the **Filter** button on the **Data** ribbon. |
| 53 | + 3. Click the drop-down arrow for the **Package names** column and enter the desired package name |
| 54 | + in the filter search box. |
| 55 | + |
| 56 | +## Data collection procedure |
| 57 | + |
| 58 | +Prerequisite: Windows with Visual Studio 2015 (including C++ tools). Currently the |
| 59 | +`list-native-imports.js` script is Windows-only because it makes use of a couple VC tools for |
| 60 | +inspecting binaries: `dumpbin.exe` and `undname.exe`. |
| 61 | + |
| 62 | + 1. Create a new empty Node.js project with `npm init`. |
| 63 | + 2. Install all targeted packages containing native modules. Yes, unfortunately this process |
| 64 | + requires installing and *compiling* all the native modules, because there's no other good |
| 65 | + way to determine precisely what native APIs are imported by the native modules. |
| 66 | + ``` |
| 67 | + npm install node-sass sqlite3 bcrypt ... |
| 68 | + ``` |
| 69 | + 3. Run the `list-native-imports.js` script. This writes CSV data to `stdout`; redirect to a `.CSV` |
| 70 | + file to save it. |
0 commit comments