0.6.1 • Published 8 years ago

closure-compiler-service v0.6.1

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

closure-compiler-service

Compile JavaScript with the Google Closure compiler service. No Java dependency.

Installation

# npm -g install closure-compiler-service

Usage

Command Line

Output is written to stdout, and can thus be redirected to a file:

$ closure-service input.js > input.min.js

Module

var ccs = require('closure-compiler-service');
var input = fs.readFileSync('input.js');

/**
 * Compile a string of JavaScript with the Closure compiler service
 *
 * @param {String|Buffer} js_code - JavaScript code to compile
 * @param {Object} [options] - API options
 * @param {Function} [callback](errs, warns, code) - defaults to console output
 */
ccs.compile(input, function(errs, warns, code) {
  // `code` is the compiled result
});

ccs.compile optionally takes an options object as the second argument (before the callback function), which are passed to the API:

ccs.compile(js_code, {
  compilation_level: 'WHITESPACE_ONLY'
}, function(errs, warns, code) {
  // ...
});

Pass an array to stipulate multiple values for the same option:

ccs.compile(js_code, {
  code_url: [url1, url2 /*, ... */]
}, function(errs, warns, code) {
  // ...
});

js_code may be null if using code_url to provide code.

Default Options

output_format     = 'json' // you won't want to change this
output_info       = ['compiled_code', 'errors', 'warnings']
compilation_level = 'SIMPLE_OPTIMIZATIONS'

License

This software is released under the terms of the MIT license. See LICENSE.

0.6.1

8 years ago

0.6.0

8 years ago

0.5.1

8 years ago

0.5.0

9 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago