Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-closure-compiler

Package Overview
Dependencies
Maintainers
4
Versions
2007
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-closure-compiler

Check, compile, optimize and compress Javascript with Closure-Compiler

  • 20241114.0.0-nightly
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created

What is google-closure-compiler?

The google-closure-compiler npm package is a powerful tool for optimizing JavaScript code. It can be used to minify, transpile, and optimize JavaScript, making it faster and more efficient. It also provides advanced features like dead code elimination, type checking, and more.

What are google-closure-compiler's main functionalities?

Minification

This feature allows you to minify JavaScript files, reducing their size and improving load times. The code sample demonstrates how to use the google-closure-compiler to minify a JavaScript file.

const closureCompiler = require('google-closure-compiler').compiler;
const compiler = new closureCompiler({
  js: 'input.js',
  compilation_level: 'SIMPLE',
  js_output_file: 'output.min.js'
});
compiler.run((exitCode, stdOut, stdErr) => {
  console.log(stdOut);
  console.error(stdErr);
});

Transpilation

This feature allows you to transpile JavaScript code from one version of ECMAScript to another. The code sample demonstrates how to transpile ECMAScript 6 code to ECMAScript 5 using google-closure-compiler.

const closureCompiler = require('google-closure-compiler').compiler;
const compiler = new closureCompiler({
  js: 'input.js',
  language_in: 'ECMASCRIPT6',
  language_out: 'ECMASCRIPT5',
  js_output_file: 'output.transpiled.js'
});
compiler.run((exitCode, stdOut, stdErr) => {
  console.log(stdOut);
  console.error(stdErr);
});

Dead Code Elimination

This feature allows you to eliminate dead code, which is code that is never executed, from your JavaScript files. The code sample demonstrates how to use the google-closure-compiler to perform dead code elimination.

const closureCompiler = require('google-closure-compiler').compiler;
const compiler = new closureCompiler({
  js: 'input.js',
  compilation_level: 'ADVANCED',
  js_output_file: 'output.optimized.js'
});
compiler.run((exitCode, stdOut, stdErr) => {
  console.log(stdOut);
  console.error(stdErr);
});

Type Checking

This feature allows you to perform type checking on your JavaScript code, helping to catch type-related errors. The code sample demonstrates how to enable type checking using google-closure-compiler.

const closureCompiler = require('google-closure-compiler').compiler;
const compiler = new closureCompiler({
  js: 'input.js',
  jscomp_warning: 'checkTypes',
  js_output_file: 'output.checked.js'
});
compiler.run((exitCode, stdOut, stdErr) => {
  console.log(stdOut);
  console.error(stdErr);
});

Other packages similar to google-closure-compiler

Keywords

FAQs

Package last updated on 14 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc