0.1.15 • Published 9 years ago

closure-compiler-stream v0.1.15

Weekly downloads
176
License
MIT
Repository
github
Last release
9 years ago

#closure-compiler-stream Streaming interface for closure compiler.

##Installation Add to your devDependencies:

  "dependencies": {...},
  "devDependencies": {
    "closure-compiler-stream": "~0.1.15"
  },
  ...

or install directly:

npm install --save-dev closure-compiler-stream

then import in your build script:

var closure = require('closure-compiler-stream');

##Usage As a simple streaming compiler:

var closure = require('closure-compiler-stream'),
  fs = require('fs');

// As an intermediary step in a flow
fs.createReadStream('path/to/js/src')
  .pipe(closure())
  .pipe(fs.createWriteStream('path/to/minified.js'));

// As the terminus in a flow
fs.createReadStream('path/to/js/src')
  .pipe(closure({
    js_output_file: 'path/to/minified.js'
  }));

With streaming build tools like gulp:

var gulp = require('gulp'),
  closure = require('closure-compiler-stream'),
  sourcemaps = require('gulp-sourcemaps');

// Basic compile
gulp.task('closure', function () {
  return gulp.src('path/to/js/*.js')
    .pipe(closure())
    .pipe(gulp.dest('path/to/minified/js/'));
});

// With sourcemaps
gulp.task('closure:sourcemap', function () {
  return gulp.src('path/to/js/*.js')
    .pipe(sourcemaps.init())
    .pipe(closure())
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('path/to/minified/js/'));
});

##API

var writableStream = closure(options);

options is a map of flags to invoke the compiler with. Options accepts one additional key jar, which can be a string path to a Closure Compiler jar file - use this to override the version of Closure Compiler to use.

To specify modules use the following schema:

module: [
  ['module_name:#files:deps:', 'sourceFile1.js', 'sourceFile2.js']
];

which would be outputted as the flags:

--module module_name:#files:deps: --js sourceFile1.js --js sourceFile2.js

Returns a Writable stream.

0.1.15

9 years ago

0.1.14

10 years ago

0.1.13

10 years ago

0.1.12

10 years ago

0.1.11

10 years ago

0.1.10

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago