{"id":25082,"library":"closure-compiler-stream","title":"closure-compiler-stream","description":"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.","status":"active","version":"0.1.15","language":"javascript","source_language":"en","source_url":"https://github.com/davidrekow/closure-compiler-stream","tags":["javascript","closure","closure compiler","stream","gulp"],"install":[{"cmd":"npm install closure-compiler-stream","lang":"bash","label":"npm"},{"cmd":"yarn add closure-compiler-stream","lang":"bash","label":"yarn"},{"cmd":"pnpm add closure-compiler-stream","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package uses CommonJS. ESM import may not work without a bundler.","wrong":"import closure from 'closure-compiler-stream';","symbol":"default","correct":"const closure = require('closure-compiler-stream');"},{"note":"If using a bundler or ESM environment, default import works (package has no named exports).","wrong":"","symbol":"default","correct":"import closure from 'closure-compiler-stream';"},{"note":"Do not access .default; the module directly exports the function.","wrong":"var closure = require('closure-compiler-stream').default;","symbol":"default","correct":"var closure = require('closure-compiler-stream');"}],"quickstart":{"code":"const closure = require('closure-compiler-stream');\nconst fs = require('fs');\n\n// Compile JavaScript from a file and output to another file\nfs.createReadStream('input.js')\n  .pipe(closure())\n  .pipe(fs.createWriteStream('output.min.js'));\n\n// Or with options\nfs.createReadStream('input.js')\n  .pipe(closure({ compilation_level: 'SIMPLE_OPTIMIZATIONS' }))\n  .pipe(fs.createWriteStream('output.min.js'));\n","lang":"javascript","description":"Creates a read stream from a source file, pipes through the Closure Compiler, and writes the minified output to another file."},"warnings":[{"fix":"Ensure Java (JRE) is installed and available in PATH.","message":"The module requires Java to be installed because it spawns the Closure Compiler Java jar.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Refer to the Closure Compiler flags documentation and use correct flag names.","message":"Options passed to the stream are flags for the Closure Compiler. Not all options are validated; misspelled flags may be ignored silently.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always pipe from a readable stream into closure() and then to a writable stream.","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Migrate to google-closure-compiler package which provides a similar API and is actively maintained.","message":"The package is not actively maintained; last release was 0.1.15 in 2016. Consider using more modern alternatives like google-closure-compiler.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install Java (JRE) and ensure 'java' command is available.","cause":"Java is not installed or not in PATH.","error":"Error: spawn java ENOENT"},{"fix":"Ensure piping is set up correctly: source.pipe(closure()).pipe(dest);","cause":"Attempting to write to the stream after it has ended, often due to incorrect piping.","error":"Error: write after end"},{"fix":"Use require('closure-compiler-stream') and call it directly as closure().","cause":"Importing the module incorrectly, e.g., as an ESM default import without bundler or using .default.","error":"TypeError: closure is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}