ClosureWebpackPlugin

npm version

This plugin supports the use of Google's Closure Tools with webpack.

Closure-Compiler is a full optimizing compiler and transpiler. It offers unmatched optimizations, provides type checking and can easily target transpilation to different versions of ECMASCRIPT.

Clousre-Library is a utility library designed for full compatibility with Closure-Compiler.

Note: This plugin is a very early beta and currently uses a custom build of closure-compiler while necessary changes are integrated back into the main compiler repository. Only the java version of closure-compiler is currently supported.

Usage example

const ClosurePlugin = require('closure-webpack-plugin');

new ClosurePlugin({mode: 'STANDARD'}, {
  // compiler flags here
  //
  // for debuging help, try these:
  //
  // formatting: 'PRETTY_PRINT'
  // debug: true
})

Options

Compiler Flags

The plugin controls several compiler flags. The following flags should not be used in any mode:

Aggressive Bundle Mode

In this mode, the compiler rewrites CommonJS modules and hoists require calls. Some modules are not compatible with this type of rewritting. In particular, hoisting will cause the following code to execute out of order:

const foo = require('foo');
addPolyfillToFoo(foo);
const bar = require('bar');

Aggressive Bundle Mode utilizes a custom runtime in which modules within a chunk file are all included in the same scope. This avoids the cost of small modules.

In Aggressive Bundle Mode, a file can only appear in a single output chunk. Use the Commons Chunk Plugin to split duplicated files into a single output chunk.

Tips for Use

Maintainers


      Chad Killingsworth


      Joshua Wiens