build-system/tasks/dep-check.js
/**
 * Flattens the graph to easily run through the Rules. Original graph
 * would be nested ModuleDef's wherein the top level are entry points
 * with nested dependencies. We flatten it so all we have are individual
 * modules and their imports as well as making the entries unique.
 *
 * @param {!ModuleDef} entryModule
 * @return {!ModuleDef}
 */
Flattens the graph to easily run through the Rules. Original graph
would be nested ModuleDef's wherein the top level are entry points
with nested dependencies. We flatten it so all we have are individual
modules and their imports as well as making the entries unique.


Flattens the graph to easily run through the Rules . Original graph would be nested ModuleDef ' s wherein the top level are entry points with nested dependencies . We flatten it so all we have are individual modules and their imports as well as making the entries unique .
function flattenGraph(entryPoints) {
  entryPoints = entryPoints.map(entryPoint => entryPoint.deps);
  return flatten(entryPoints)
      .reduce((acc, cur, i, arr) => {
        var name = cur.name;
        if (!acc[name]) {
          acc[name] = Object.keys(cur.deps)
              .map(x => cur.deps[x].replace(absPathRegExp, ''));
        }
        return acc;
      }, Object.create(null));
}
function flattenGraph ( entryPoints ) { entryPoints = entryPoints . map ( entryPoint => entryPoint . deps ) ; return flatten ( entryPoints ) . reduce ( ( acc , cur , i , arr ) => { var name = cur . name ; if ( ! acc [ name ] ) { acc [ name ] = Object . keys ( cur . deps ) . map ( x => cur . deps [ x ] . replace ( absPathRegExp , '' ) ) ; } return acc ; } , Object . create ( null ) ) ; }
Flattens the graph to easily run through the Rules.
Flattens the graph to easily run through the Rules .
// Flatten the graph by just getting all the deps from all // the entry points. // Now make the graph have unique entries // Get rid of the absolute path for minimatch'ing