{"id":22154,"library":"rollup-plugin-optimize-js","title":"rollup-plugin-optimize-js","description":"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.","status":"deprecated","version":"0.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/ezekielchentnik/rollup-plugin-optimize-js","tags":["javascript","rollup","rollup-plugin","optimize-js","performance"],"install":[{"cmd":"npm install rollup-plugin-optimize-js","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-optimize-js","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-optimize-js","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core optimization library that this plugin wraps.","package":"optimize-js","optional":false},{"reason":"Peer dependency; plugin is designed for Rollup bundler.","package":"rollup","optional":false}],"imports":[{"note":"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.","wrong":"const optimizeJs = require('rollup-plugin-optimize-js').default","symbol":"optimizeJs","correct":"import optimizeJs from 'rollup-plugin-optimize-js'"},{"note":"The plugin is a function that returns a plugin object, not a class constructor.","wrong":"new optimizeJs()","symbol":"optimizeJs (as plugin in rollup config)","correct":"optimizeJs()"},{"note":"CommonJS require works directly as the package is CJS.","wrong":"","symbol":"optimizeJs (CommonJS require)","correct":"const optimizeJs = require('rollup-plugin-optimize-js');"}],"quickstart":{"code":"// rollup.config.js\nimport optimizeJs from 'rollup-plugin-optimize-js';\nimport { uglify } from 'rollup-plugin-uglify';\nimport buble from 'rollup-plugin-buble';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'bundle.js',\n    format: 'iife',\n    sourcemap: true\n  },\n  plugins: [\n    buble(),\n    uglify({\n      compress: {\n        negate_iife: false // avoid conflict with optimize-js\n      }\n    }),\n    optimizeJs()\n  ]\n};","lang":"javascript","description":"Shows how to integrate the plugin in a Rollup config, applying it after uglify to optimize invoked functions."},"warnings":[{"fix":"Consider using Rollup's built-in optimizations or manually applying optimize-js as a post-build step.","message":"Package is unmaintained since 2017. No support for modern Rollup versions (Rollup > 1.x).","severity":"deprecated","affected_versions":">=0.0.4"},{"fix":"Downgrade Rollup to 0.x or switch to an alternative plugin.","message":"Plugin may cause errors with Rollup 1.x due to API changes (e.g., transformBundle removed).","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure order: other plugins -> minify -> optimizeJs.","message":"Must be placed after minification plugins (e.g., uglify) in the plugin list, otherwise it may not work correctly.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set uglify compress option 'negate_iife: false'.","message":"Uglify's 'negate_iife' compress option should be false to avoid conflicting with optimize-js's work.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'npm install rollup-plugin-optimize-js --save-dev' and ensure it's in your dependencies.","cause":"Package not installed or not in node_modules.","error":"Error: Could not resolve 'rollup-plugin-optimize-js'"},{"fix":"Use 'const optimizeJs = require('rollup-plugin-optimize-js');' in CommonJS, or 'import optimizeJs from 'rollup-plugin-optimize-js';' in ES6.","cause":"Importing incorrectly, e.g., using default import on CJS that expects named export.","error":"TypeError: optimizeJs is not a function"},{"fix":"Downgrade Rollup to 0.x or use a different plugin that supports Rollup 1.x+.","cause":"Using Rollup 1.x+ where transformBundle was removed.","error":"Error: The transformBundle hook used by plugin optimize-js is deprecated","affected_versions":">=1.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}