This is a separate utility node package for Closure Library related to dependency management with Closure files.
Install via npm:
npm install google-closure-deps
To use the CLI below from any directory install the package globally:
npm install -g google-closure-deps
Command Line Interface
closure-make-deps is a utility to produce a dependency file for Closure
Library's debug code loader. Closure Library is capable of loading code in a web
browser or in Node but must know the dependency graph ahead of time. Generally
this is done by loading Closure's base.js file and then loading a dependency
file containing repeated calls to goog.addDependency`. Closure comes bundled
with a file named deps.js for itself and is capable of auto loading this file.
get-js-version is a generally useful utility that determines the highest level
the Closure Compiler's FeatureSet#version method and should match what
goog.addDependency expects for a
lang load flag.
$ echo "const foo = 0;" | get-js-version es6
This Node module also exposes standard functions to parse Closure files and retrieve a dependency graph.
This is an in-code example for clarity, but there are also functions to parse files rather than strings.
const parser depGraph = ;// A file that provides "goog" is required for any file that references Closure.// Usually this is Closure's base.js file.const goog = parserdependency;const firstFile =parserdependency;const secondFile = parserdependency;const graph = goog firstFile secondFile;graph; // [goog, firstFile, secondFile]graphdepsBySymbol; // firstFilegraphdepsByPath; // secondFile
This also supports parsing ES6 modules now that Closure Library has support for them!
const parser depGraph = ;// A file that provides "goog" is required for any file that references Closure.// Usually this is Closure's base.js file.const goog = parserdependency;const firstFile = parserdependency;const secondFile = parserdependency;const thirdFile = parserdependency;const graph = goog firstFile secondFile thirdFile;graph; // [goog, firstFile, secondFile, thirdFile]