Skip to content

How Does It Work

The task is to compare all exports and imports of the package. Anything not imported but exported is an unused export.

Algorithm

  1. collect all package exports into exports Set
  2. traverse all files where package import may occur
  3. if the import is found, remove it from exports Set
  4. if the size of the exports Set became equal to 0, then exit with success
  5. if the exports Set size is not equal to 0, then exit with an error

How It Optimized

  1. file reading is divided into batches
  2. file is not immediately converted to AST. First the import of the package is searched for in the file. createReadStream is used
  3. there is an instant exit with success as soon as the size of exports Set is equal to zero
  4. swc is used to parse the AST
  5. fdir is used as project crawler