Google Closure Compiler - Mac OS Native
raw JSON → 20260428.0.0 verified Fri May 01 auth: no javascript
Mac OS native binary distribution of the Google Closure Compiler, a JavaScript optimizer and minifier. Version 20260428.0.0 corresponds to the Closure-Compiler release 20260428. Frequent updates (weekly). This package is one of platform-specific packages; the main entry point is 'google-closure-compiler'. It automatically detects the platform and installs the appropriate binary. Key differentiator: provides a native Java binary for macOS (x64 and arm64) instead of requiring a separate Java runtime installation, but still requires Java to be available. Unlike other minifiers (Terser, esbuild), it performs advanced optimizations like type-based inlining and dead code elimination. Not intended for direct import; use the main package.
Common errors
error Error: Cannot find module 'google-closure-compiler-macos' ↓
cause Installed the platform package instead of the main package.
fix
Run: npm install google-closure-compiler
error Error: Java not found. Please install Java and ensure it is in your PATH. ↓
cause Java runtime is not installed.
fix
Install OpenJDK 8+ and add 'java' to PATH.
error Error: The platform "win32" is incompatible with this module. ↓
cause Using macos package on non-Mac OS.
fix
Install the main package: npm install google-closure-compiler
Warnings
gotcha Install the main 'google-closure-compiler' package, not the platform-specific package like 'google-closure-compiler-macos'. ↓
fix npm install google-closure-compiler
breaking Java is required at runtime; the package only provides the closure-compiler.jar and a Java wrapper. Ensure Java 8+ is installed. ↓
fix Install Java 8 or later (e.g., via OpenJDK).
gotcha The compiler binary is platform-specific; the main package automatically selects the correct platform package (linux, macos, or windows). ↓
fix Do not manually install platform packages; let the main package handle it.
Install
npm install google-closure-compiler-macos yarn add google-closure-compiler-macos pnpm add google-closure-compiler-macos Imports
- compile wrong
import { compile } from 'google-closure-compiler-macos'correctimport { compile } from 'google-closure-compiler' - closureCompiler wrong
import closureCompiler from 'google-closure-compiler-macos'correctimport closureCompiler from 'google-closure-compiler'
Quickstart
// Install: npm install google-closure-compiler
import { compile } from 'google-closure-compiler';
const compilation = await compile({
compilation_level: 'ADVANCED',
js: ['src/**/*.js'],
js_output_file: 'dist/bundle.min.js',
language_in: 'ECMASCRIPT_2020',
language_out: 'ECMASCRIPT5',
rewrite_polyfills: false,
});
if (compilation.errors) {
console.error('Compilation errors:', compilation.errors);
} else {
console.log('Compiled output:', compilation.outputFiles);
}