0.1.9 • Published 11 years ago
oog v0.1.9
oog
Use Google Closure Library in node.js.
Oog doesn't provide the libraries, but it makes it simple to use and distribute code that relies on them.
Installation
npm install oogFor command-line usage:
npm install -g oogUsage
example.js:
goog.addDependency('../../../helloworld.js', ['helloworld'], []);example/helloworld.js:
goog.provide('helloworld');
helloworld.sayHello = function(name) {
console.log('Hello, ' + name);
}
goog.exportSymbol('helloworld.sayHello', helloworld.sayHello);You can load Closure libraries:
oog = require 'oog'
goog = oog 'closure-library/closure'
goog.load 'example.js'
helloworld = goog.require 'helloworld'
helloworld.sayHello 'World'You can call functions in Closure Libraries from the command line:
oog closure-library/closure example.js -m helloworld.sayHello WorldAfter compiling, you don't need to include the path to the Closure Library.
python closure-library/closure/bin/build/closurebuilder.py \
--root closure-library \
--root example \
--namespace "helloworld" \
--output_mode=compiled \
--compiler_jar=compiler.jar > example-compiled.jsoog example-compiled.js -m helloworld.sayHello Worldrequire('oog')('example-compiled.js').require('helloworld').sayHello('World')