jsc, JavaScript Compiler

by Davide Saurino
http://github.com/sub/jsc

DESCRIPTION:

Simple Ruby API to Google Closure Compiler Web service.

FEATURES:

With jsc you can compile your JavaScript code throught Google Closure Compiler REST service.

The package comes with a jsc commands which accepts several options, run:

jsc --help

for help.

More in details:

  • Ruby API actually is a single function call (ex: JSCompiler.compile(file_name, “statistics”, “SIMPLE_OPTIMIZATIONS”) )

  • Handling of JSON responses, parse and print them (same output of the Google web interface!)

  • Handling of Server Errors responses

  • Compile a piece of code, a file or a whole directory

  • Emacs snippet to compile code your code for errors and warnings

Check Google API Reference for more info about accepted parameters.

SYNOPSIS:

Get compiled code, if no errors are found:

ruby bin/jsc js/compiled_code.js

Compile a file, check for errors:

ruby bin/jsc js/errors.js -e

Compile a file, check for warnings:

ruby bin/jsc js/warnings.js -w

Compile a file and get compression stats:

ruby bin/jsc js/compiled_code.js -s

Compile a piece of code, check for errors:

ruby bin/jsc -e -c "function("

Compile a file and get compiled code if no errors or warnings are found:

ruby bin/jsc js/compiled_code.js -a

EMACS SNIPPETS

Wants to compile your code right from Emacs?

Copy

plugins/jsc.el

to your emacs load-path and restart Emacs.

Now, select the code to compile and run:

  • CcJe to check for errors

  • CcJw to check for warnings.

REQUIREMENTS:

jsc requires the bones gem.

INSTALL:

If you have gemcutter in your gem sources, run:

[sudo] gem install jsc

LICENSE:

(The MIT License)

Copyright © 2009 Davide Saurino

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.