{"id":26461,"library":"task-closure-tools","title":"task-closure-tools","description":"Core library for Google Closure Tools tasks, providing Compiler (JS minification using the Closure Compiler), Builder (concatenation and optional compilation), and DepsWriter (dependency graph generation for deps.js files). Current version 0.1.10, last updated June 2015 (infrequent updates). Primarily used as a base for Grunt plugins (grunt-closure-tools) and other build systems (Mantri). Differentiators: integrates directly with Google Closure Library ecosystem, supports Java-based Closure Compiler and Python-based DepsWriter, but node >=0.8.0 only, no modern ESM support.","status":"maintenance","version":"0.1.10","language":"javascript","source_language":"en","source_url":"https://github.com/thanpolas/task-closure-tools","tags":["javascript","Closure Compiler","minification","Closure Builder","Google Closure Library","Closure tools","Closure DepsWriter","Performance"],"install":[{"cmd":"npm install task-closure-tools","lang":"bash","label":"npm"},{"cmd":"yarn add task-closure-tools","lang":"bash","label":"yarn"},{"cmd":"pnpm add task-closure-tools","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package has no default export; common usage is via grunt plugin or requiring specific submodules.","wrong":"const taskClosureTools = require('task-closure-tools')","symbol":"taskClosureTools","correct":"import taskClosureTools from 'task-closure-tools'"},{"note":"Named export available; use destructured import in ESM, or access via property in CJS.","wrong":"const Compiler = require('task-closure-tools').Compiler","symbol":"Compiler","correct":"import { Compiler } from 'task-closure-tools'"},{"note":"Named export for Builder class.","wrong":null,"symbol":"Builder","correct":"import { Builder } from 'task-closure-tools'"},{"note":"Named export for DepsWriter class.","wrong":null,"symbol":"DepsWriter","correct":"import { DepsWriter } from 'task-closure-tools'"}],"quickstart":{"code":"import { Compiler, Builder, DepsWriter } from 'task-closure-tools';\n\n// Example: compile a single JS file\nconst compiler = new Compiler({\n  closureLibraryPath: './node_modules/google-closure-library',\n  bootstrap: false\n});\n\ncompiler.compile({\n  js: 'src/main.js',\n  compilation_level: 'ADVANCED_OPTIMIZATIONS',\n  js_output_file: 'dist/bundle.min.js',\n  extra_annotation_name: 'api'\n}, function(err, stdout, stderr) {\n  if (err) { console.error('Compilation failed:', err); }\n  else { console.log('Compilation succeeded:', stdout); }\n});\n\n// Builder: concatenate dependencies and optionally compile\nconst builder = new Builder({\n  closureLibraryPath: './node_modules/google-closure-library'\n});\nbuilder.build({\n  inputs: 'src/main.js',\n  compile: true,\n  output_file: 'dist/bundle.js'\n}, function(err, stdout) {\n  if (err) { console.error('Build failed:', err); }\n  else { console.log('Build completed'); }\n});\n\n// DepsWriter: generate deps.js\nconst depsWriter = new DepsWriter({\n  closureLibraryPath: './node_modules/google-closure-library'\n});\ndepsWriter.writeDeps({\n  root: ['src', 'test'],\n  output_file: 'dist/deps.js'\n}, function(err) {\n  if (err) { console.error('Deps write failed:', err); }\n  else { console.log('Deps written'); }\n});","lang":"javascript","description":"Shows basic usage of Compiler, Builder, and DepsWriter for compilation, bundling, and dependency generation."},"warnings":[{"fix":"Consider using official Closure Compiler npm package 'google-closure-compiler' or other modern build tools.","message":"Package last updated June 2015; no longer actively maintained. May have compatibility issues with modern Node.js versions (>=10).","severity":"gotcha","affected_versions":">=0.1.10"},{"fix":"Ensure Java and Python are installed and available in PATH.","message":"Requires Java Runtime Environment (JRE) to run the Closure Compiler and Python to run DepsWriter. Not explicitly mentioned in npm metadata.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Install google-closure-library and pass its path (e.g., './node_modules/google-closure-library').","message":"Closure Library path must be provided manually via options; package does not automatically resolve it.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Refer to official Closure Compiler documentation for valid compilation_level and other options.","message":"Compiler and Builder options are passed directly to the underlying Java command; incorrect flags may cause silent failures.","severity":"gotcha","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":"Run `npm install task-closure-tools` and use require('task-closure-tools') or import { ... } from 'task-closure-tools'.","cause":"Package not installed or incorrect import path.","error":"Error: Cannot find module 'task-closure-tools'"},{"fix":"Install Java (JRE) version 8 or later and ensure java command is accessible.","cause":"Java Runtime Environment not installed or not in PATH.","error":"Java not found. Please install Java."},{"fix":"Install Python 2.7 (older, may work) or Python 3 and ensure python command is in PATH.","cause":"Python not installed for DepsWriter.","error":"python: not found"},{"fix":"Use named imports: import { Compiler, Builder, DepsWriter } from 'task-closure-tools'.","cause":"Using default import instead of named exports.","error":"TypeError: taskClosureTools is not a function"},{"fix":"Set closureLibraryPath option to the root of the installed google-closure-library package.","cause":"Closure Library path not correctly configured or missing.","error":"Error: ENOENT: no such file or directory, open '.../closure-library/closure/goog/base.js'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}