Registry / web-framework / rollup-plugin-optimize-js

rollup-plugin-optimize-js

JSON →
library0.0.4jsnpmunverified

Rollup plugin to run minified bundles through the optimize-js tool, which wraps immediately-invoked or likely-to-be-invoked functions in parentheses to improve initial parsing and execution speed. Current version is 0.0.4, last published in 2017 and appears to be unmaintained (no recent updates, repository archived or inactive). Differentiator: it applies optimize-js after minification to restore optimizations that might have been undone by UglifyJS. Consider using modern alternatives like Rollup's built-in optimization or other plugins.

npm install rollup-plugin-optimize-js
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-OPTI
R
rollup-plugin-optimize-js
web-frameworkjavascriptv0.0.4
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

optimizeJs
✓ import optimizeJs from 'rollup-plugin-optimize-js'
✗ const optimizeJs = require('rollup-plugin-optimize-js').default
Default export, use default import or require with no .default (though require works as it's CJS). In TypeScript, use default import if module allows.
optimizeJs (as plugin in rollup config)
✓ optimizeJs()
✗ new optimizeJs()
The plugin is a function that returns a plugin object, not a class constructor.
optimizeJs (CommonJS require)
✓ const optimizeJs = require('rollup-plugin-optimize-js');
CommonJS require works directly as the package is CJS.

Shows how to integrate the plugin in a Rollup config, applying it after uglify to optimize invoked functions.

// rollup.config.js import optimizeJs from 'rollup-plugin-optimize-js'; import { uglify } from 'rollup-plugin-uglify'; import buble from 'rollup-plugin-buble'; export default { input: 'src/index.js', output: { file: 'bundle.js', format: 'iife', sourcemap: true }, plugins: [ buble(), uglify({ compress: { negate_iife: false // avoid conflict with optimize-js } }), optimizeJs() ] };
Debug
Known issues
deprecatedPackage is unmaintained since 2017. No support for modern Rollup versions (Rollup > 1.x).
fix
Consider using Rollup's built-in optimizations or manually applying optimize-js as a post-build step.
affects: >=0.0.4
breakingPlugin may cause errors with Rollup 1.x due to API changes (e.g., transformBundle removed).
fix
Downgrade Rollup to 0.x or switch to an alternative plugin.
affects: >=1.0.0
gotchaMust be placed after minification plugins (e.g., uglify) in the plugin list, otherwise it may not work correctly.
fix
Ensure order: other plugins -> minify -> optimizeJs.
affects: >=0.0.0
gotchaUglify's 'negate_iife' compress option should be false to avoid conflicting with optimize-js's work.
fix
Set uglify compress option 'negate_iife: false'.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Could not resolve 'rollup-plugin-optimize-js'
Package not installed or not in node_modules.
fix
Run 'npm install rollup-plugin-optimize-js --save-dev' and ensure it's in your dependencies.
TypeError: optimizeJs is not a function
Importing incorrectly, e.g., using default import on CJS that expects named export.
fix
Use 'const optimizeJs = require('rollup-plugin-optimize-js');' in CommonJS, or 'import optimizeJs from 'rollup-plugin-optimize-js';' in ES6.
Error: The transformBundle hook used by plugin optimize-js is deprecated
Using Rollup 1.x+ where transformBundle was removed.
fix
Downgrade Rollup to 0.x or use a different plugin that supports Rollup 1.x+.
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
optimize-jsrequiredCore optimization library that this plugin wraps.
rolluprequiredPeer dependency; plugin is designed for Rollup bundler.
Agent activity
2 hits · last 30 days
node
2
Resources
rollup-plugin-optimize-js — npm install rollup-plugin-optimize-js · libregistry