rollup-plugin-optimize-js
v0.0.4
Published
Rollup plugin to easily run your bundles through optimize-js, post minifying
Downloads
231
Maintainers
Readme
rollup-plugin-optimize-js
Run your Rollup bundles through optimize-js post minifying.
This will optimize a JavaScript file for faster initial execution and parsing, by wrapping all immediately-invoked functions or likely-to-be-invoked functions in parentheses. By default Rollup does similar optimizations, however, this will apply the optimization to all functions, and/or handle situations where minifying your bundle undos previous optimizations.
See optimize-js for more info and details on when it makes sense for this optimization.
Demo
Usage Example
Install
npm i rollup-plugin-optimize-js --save
Use plugin in your rollup.config.js
, be sure to add after uglify
const buble = require('rollup-plugin-buble')
const uglify = require('rollup-plugin-uglify')
const optimizeJs = require('rollup-plugin-optimize-js')
module.exports = {
entry: 'src/index.js',
plugins: [
buble(),
uglify({
"compress": {
"negate_iife": false, // not required, similar optimization
// omitted for brevity
}
}),
optimizeJs() // occurs after uglify
],
targets: [
{
sourceMap: true,
format: 'iife'
}
]
}
Thanks
Nolan Lawson for the excellent JavaScript