closure-compile
Version: 5.1.2

closure-compile: Compile and compress JavaScript source with the Google Closure Compiler

This library exposes the Google Closure compiler to Racket.

The module requires runtime access to Java; the value of (find-executable-path "java") should point to a valid Java executable.

 (require (planet dyoo/closure-compile:1:2))
(closure-compile code [compilation-level])  string?
  code : string?
  compilation-level : (or/c 'whitespace 'simple 'advanced)
   = 'simple
closure-compile takes the given code and passes it to the Closure compiler. It should return a minified version of code. compilation-level adjusts the optimization that the Closure compiler will perform.

If anything bad happens, it will raise an exn:fail and hold the error message in the exception’s exn-message.

Examples:

> (closure-compile "alert('hello ' + 'world');")

"alert(\"hello world\");\n"

> (closure-compile "{this should raise an error")

closure-compile: stdin:1: ERROR - Parse error. missing ;

before statement

stdin:1: ERROR - Parse error. missing } in compound

statement

2 error(s), 0 warning(s)

> (closure-compile "alert('hello, I see: ' + (3 + 4) + '!');"
                   'whitespace)

"alert(\"hello, I see: \"+(3+4)+\"!\");\n"

> (closure-compile "alert('hello, I see: ' + (3 + 4) + '!');"
                   'simple)

"alert(\"hello, I see: 7!\");\n"

> (closure-compile "\n                       var f = function(x) { \n                           return x * x; \n                       };\n                       alert( f(3) );")

"var f=function(a){return a*a};alert(f(3));\n"

> (closure-compile "\n                       var f = function(x) { \n                           return x * x; \n                       };\n                       alert( f(3) );"
  
  
  
  
                   'advanced)

"alert(9);\n"