uber-compiler
raw JSON → 0.4.7 verified Fri May 01 auth: no javascript maintenance
Compiles client-side JS and CSS using Google Closure Compiler, Closure Templates, and LESS. Version 0.4.7 runs on Node.js >= 0.4.1. It watches files for changes, caches compiled output, and supports custom warnings/compile modes. Unlike standalone build tools, it integrates directly into a Node.js server and auto-recompiles on file changes. Maintenance appears stalled with no recent updates.
Common errors
error Error: Path must be absolute: relative/path/to/js ↓
cause Providing relative paths in jsPaths or cssPaths.
fix
Use absolute paths by prefixing with path.join(__dirname, ...) or path.resolve().
error Error: Cannot find module 'google-closure-compiler' ↓
cause Missing google-closure-compiler dependency, which must be installed globally.
fix
Run: npm i -g google-closure-compiler
error ReferenceError: require is not defined ↓
cause Attempting to use CommonJS require in an ESM module file.
fix
Use import uberCompiler from 'uber-compiler'; instead, or rename file to .cjs.
Warnings
gotcha The jsPaths and cssPaths arrays must contain absolute paths. Relative paths cause 'Path must be absolute' errors. ↓
fix Use path.join with process.cwd() or __dirname to create absolute paths.
gotcha Dependency google-closure-compiler is a large binary and must be installed globally (npm i -g google-closure-compiler) before using uber-compiler. ↓
fix Install google-closure-compiler globally: npm i -g google-closure-compiler
deprecated This package is no longer actively maintained. The last release was in 2012. Alternatives like webpack or gulp are recommended. ↓
fix Migrate to modern build tools such as webpack, gulp, or rollup.
gotcha The 'endCallback' option is called after compilation completes but is not passed any arguments, making error handling difficult. ↓
fix Use process.on('uncaughtException') or wrap run() in try/catch for error handling.
Install
npm install uber-compiler yarn add uber-compiler pnpm add uber-compiler Imports
- default wrong
const uberCompiler = require('uber-compiler');correctimport uberCompiler from 'uber-compiler'; - uberCompiler function wrong
const { uberCompiler } = require('uber-compiler');correctimport uberCompiler from 'uber-compiler'; const compiler = uberCompiler(options); - getJsFilename wrong
import { getJsFilename } from 'uber-compiler';correctimport uberCompiler from 'uber-compiler'; const compiler = uberCompiler(options); const jsFile = compiler.getJsFilename();
Quickstart
const path = require('path');
const uberCompiler = require('uber-compiler');
const rootPath = process.cwd();
const options = {
jsPaths: [
path.join(rootPath, 'public/js/lib/jquery-1.7.2.js'),
path.join(rootPath, 'public/js/lib/underscore.js'),
path.join(rootPath, 'public/js/lib/backbone.js'),
path.join(rootPath, 'public/js/init.js'),
path.join(rootPath, 'public/js/model/'),
path.join(rootPath, 'public/js/view/'),
path.join(rootPath, 'public/js/router/'),
path.join(rootPath, 'public/js/main.js')
],
cssPaths: [ path.join(rootPath, 'public/css') ],
outputDir: path.join(rootPath, 'public/cached'),
debug: false
};
const compiler = uberCompiler(options);
compiler.run();