oog

0.1.9 • Public • Published

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 oog

For command-line usage:

npm install -g oog

Usage

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 World

After 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.js
oog example-compiled.js -m helloworld.sayHello World
require('oog')('example-compiled.js').require('helloworld').sayHello('World')

Readme

Keywords

none

Package Sidebar

Install

npm i oog

Weekly Downloads

2

Version

0.1.9

License

none

Last publish

Collaborators

  • also