0.27.8 • Published 1 year ago

@liquid-js/rollup-plugin-closure-compiler v0.27.8

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

rollup-plugin-closure-compiler

GitHub license npm scope

Leverage Closure Compiler to minify and optimize JavaScript with Rollup.

Generally Closure Compiler will produce superior minification than other projects, but historically has been more difficult to use. The goal of this plugin is to reduce this friction.

Installation

npm install @liquid-js/rollup-plugin-closure-compiler --save-dev

Usage

Invoke Closure Compiler from your Rollup configuration.

// rollup.config.js
import compiler from '@liquid-js/rollup-plugin-closure-compiler'

export default {
    input: 'main.js',
    output: {
        file: 'bundle.js',
        format: 'iife'
    },
    plugins: [
        compiler()
    ]
}

If you would like to provide additional flags and options to Closure Compiler, pass them via key-value pairs.

// rollup.config.js
import compiler from '@liquid-js/rollup-plugin-closure-compiler'

export default {
    input: 'main.js',
    output: {
        file: 'bundle.js',
        format: 'iife'
    },
    plugins: [
        compiler({
            formatting: 'PRETTY_PRINT'
        })
    ]
}

Automatic Closure Configuration

This plugin will modify the enable the assume_function_wrapper output option for Closure Compiler when es format is specifed to Rollup. Note: This is overrideable via passed flags and options.

// rollup.config.js
import compiler from '@liquid-js/rollup-plugin-closure-compiler'

export default {
    input: 'main.js',
    output: {
        file: 'bundle.js',
        format: 'es'
    },
    plugins: [
        compiler()
    ]
}

If your Rollup configuration outputs an IIFE format bundle with a specified name, this plugin will add an extern to ensure the name does not get mangled. Note: This is overrideable via passed flags and options.

// rollup.config.js
import compiler from '@liquid-js/rollup-plugin-closure-compiler'

export default {
    input: 'main.js',
    output: {
        file: 'bundle.js',
        format: 'iife',
        name: 'MyAwesomeThing'
    },
    plugins: [
        compiler()
    ]
}
0.27.2

1 year ago

0.27.8

1 year ago

0.27.6

1 year ago

0.27.5

1 year ago

0.27.4

1 year ago

0.27.3

1 year ago

0.27.1

2 years ago

0.27.0

2 years ago