Teaser image of Rick Tracy

Rick Tracy

eccentric-j/rick-tracy
  • JS

A node JS library for tracing ES6 and CommonJS imports.

Goal

Prior to webpack, our JS build system started to slow down for all our separate JS apps. Instead of building them all at once with Browserify we wanted a smarter system that could look at a changed source file and find all the root applications that depended on it.

Process

  1. Researched existing tools for tracing dependencies
  2. Researched combing ES6 Promises and Streams to recursively crawl up a tree of imports without exhausting memory.
  3. Architected a class hierarchy to divide responsibilities.
  4. Implemented solution in node.
  5. Wrote unit tests.

Discoveries

  • Learned ES6 Promises
  • Made use of the graphing experience with the sass tooling
  • Learned the many nuances of transpiling with Babel from ES6 to ES5
  • It was fun writing all the code to a detective metaphor way:
    // For each lead found start a new investigation
    investigations = leads.map((lead) => {
      return this.trackDown(lead)
        .then((newSuspect) => {
          return this.interrogate(newSuspect, suspect.path);
        })
        .catch(() => {});
    });