Today I was trying to use the Google Closure compiler to build a single .js file out of several source files and their closure library dependencies:
closure-library-read-only/closure/bin/calcdeps.py -p closure-library-read-only -i bar.js -i foo.js -o compiled -c closure-compiler/compiler.jar > compiled.js
I kept getting errors like this:
Exception: Missing provider for (foo.Foo)
That sucked, since foo.js with its goog.Provide("foo.Foo") was right in the same directory with bar.js, and I even specified it explicitly on the command line.
Turns out I needed to specify "-p ." so that it'd look in the current directory for the dependency. So with a command line of:
closure-library-read-only/closure/bin/calcdeps.py -p . -p closure-library-read-only -i bar.js -i foo.js -o compiled -c closure-compiler/compiler.jar > compiled.js
I got:
Exception: Duplicate provide (goog.async.DeferredList) in ...
That seemed even weirder. Turns out calcdeps doesn't like having the same subdirectory show up twice in -p arguments. That is, "-p ." and "-p closure-library-read-only" was causing it to find the closure library twice. Okay, so we take out the second -p:
closure-library-read-only/closure/bin/calcdeps.py -p . -i bar.js -i foo.js -o compiled -c closure-compiler/compiler.jar > compiled.js
Now I get:
ERROR - namespace "foo.Foo" cannot be provided twice
Almost there: it doesn't like having foo.js explicitly provided. This actually worked:
closure-library-read-only/closure/bin/calcdeps.py -p . -i bar.js -o compiled -c closure-compiler/compiler.jar > compiled.js
1 comment:
Thank you. I had all these errors too! This probably saved me hours of frustration. You would think calcdeps could be a little more intelligent about explaining errors.
Post a Comment