Registry / devops / closure-compiler-stream

closure-compiler-stream

JSON →
library0.1.15jsnpmunverified

A streaming interface for Google Closure Compiler that provides full pipe support for Node.js streams. Version 0.1.15 is the latest stable release. It wraps the Closure Compiler Java application as a Node.js stream, allowing it to be used in gulp pipelines or with plain streams. Key differentiators from other Closure Compiler wrappers are its simple stream-based API and support for Gulp with sourcemaps. It supports module definitions and custom jar paths. The package is minimal and focuses on streaming rather than complex configuration.

npm install closure-compiler-stream
INSTALL
IMPORT
SIG · CLOSURE-COMPILER-S
C
closure-compiler-stream
devopsjavascriptv0.1.15
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const closure = require('closure-compiler-stream');
import closure from 'closure-compiler-stream';
This package uses CommonJS. ESM import may not work without a bundler.
default
import closure from 'closure-compiler-stream';
If using a bundler or ESM environment, default import works (package has no named exports).
default
var closure = require('closure-compiler-stream');
var closure = require('closure-compiler-stream').default;
Do not access .default; the module directly exports the function.

Creates a read stream from a source file, pipes through the Closure Compiler, and writes the minified output to another file.

const closure = require('closure-compiler-stream'); const fs = require('fs'); // Compile JavaScript from a file and output to another file fs.createReadStream('input.js') .pipe(closure()) .pipe(fs.createWriteStream('output.min.js')); // Or with options fs.createReadStream('input.js') .pipe(closure({ compilation_level: 'SIMPLE_OPTIMIZATIONS' })) .pipe(fs.createWriteStream('output.min.js'));
Debug
Known issues
gotchaThe module requires Java to be installed because it spawns the Closure Compiler Java jar.
fix
Ensure Java (JRE) is installed and available in PATH.
affects: >=0.1.0
gotchaOptions passed to the stream are flags for the Closure Compiler. Not all options are validated; misspelled flags may be ignored silently.
fix
Refer to the Closure Compiler flags documentation and use correct flag names.
affects: >=0.1.0
gotchaThe stream returns a Writable stream but is intended to be used in a pipeline; piping to it will cause it to consume input and produce output on the next stream.
fix
Always pipe from a readable stream into closure() and then to a writable stream.
affects: >=0.1.0
deprecatedThe package is not actively maintained; last release was 0.1.15 in 2016. Consider using more modern alternatives like google-closure-compiler.
fix
Migrate to google-closure-compiler package which provides a similar API and is actively maintained.
affects: >=0.1.0
Errors
Common errors & fixes
Error: spawn java ENOENT
Java is not installed or not in PATH.
fix
Install Java (JRE) and ensure 'java' command is available.
Error: write after end
Attempting to write to the stream after it has ended, often due to incorrect piping.
fix
Ensure piping is set up correctly: source.pipe(closure()).pipe(dest);
TypeError: closure is not a function
Importing the module incorrectly, e.g., as an ESM default import without bundler or using .default.
fix
Use require('closure-compiler-stream') and call it directly as closure().
Upgrade
Version history
0.1.15latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
closure-compiler-stream — npm install closure-compiler-stream · libregistry