{"id":11957,"library":"rollup-plugin-obfuscator","title":"Rollup Plugin for JavaScript Obfuscator","description":"rollup-plugin-obfuscator is a powerful Rollup plugin designed to integrate `javascript-obfuscator` into the build process. Unlike some alternatives, this plugin requires `javascript-obfuscator` to be installed as a separate peer dependency, ensuring users can always utilize the latest version of the obfuscator. The current stable version is 1.1.0, with updates typically aligning with new releases or needs of `javascript-obfuscator`. A key differentiator is its ability to perform obfuscation either on the entire bundle or, more efficiently, on individual files while excluding open-source dependencies, leading to significant performance improvements during the build process. It provides granular control over which files are obfuscated via include/exclude patterns and supports all configuration options available in `javascript-obfuscator` itself.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/getkey/rollup-plugin-obfuscator","tags":["javascript","rollup-plugin","vite-plugin","obfuscator","javascript-obfuscator","obfuscate","obfuscation","typescript"],"install":[{"cmd":"npm install rollup-plugin-obfuscator","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-obfuscator","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-obfuscator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core obfuscation library; required peer dependency.","package":"javascript-obfuscator","optional":false},{"reason":"The build tool this plugin extends; required peer dependency.","package":"rollup","optional":false}],"imports":[{"note":"The plugin is exported as a default export. For CommonJS, `require('rollup-plugin-obfuscator').default` is correct but less common in modern Rollup configs.","wrong":"import { obfuscator } from 'rollup-plugin-obfuscator';\nconst obfuscator = require('rollup-plugin-obfuscator');","symbol":"obfuscator","correct":"import obfuscator from 'rollup-plugin-obfuscator';"},{"note":"While not directly from this plugin, users often need Rollup types when configuring plugins in TypeScript.","symbol":"RollupOptions","correct":"import type { RollupOptions } from 'rollup';"},{"note":"For precise typing of the `options` property, import types directly from `javascript-obfuscator`, as this plugin passes them through.","symbol":"ObfuscatorOptions","correct":"import type { ObfuscatorOptions } from 'javascript-obfuscator';"}],"quickstart":{"code":"import obfuscator from 'rollup-plugin-obfuscator';\n\nexport default {\n\tinput: 'src/main.js',\n\toutput: {\n\t\tdir: 'dist',\n\t\tformat: 'esm'\n\t},\n\tplugins: [\n\t\tobfuscator({\n\t\t\t// Obfuscate the entire bundle (default is file-by-file)\n\t\t\t// global: true,\n\t\t\toptions: {\n\t\t\t\t// Your javascript-obfuscator options here\n\t\t\t\t// See what's allowed: https://github.com/javascript-obfuscator/javascript-obfuscator\n\t\t\t\tcompact: true,\n\t\t\t\tcontrolFlowFlattening: true,\n\t\t\t\tdeadCodeInjection: true,\n\t\t\t\tidentifierNamesGenerator: 'hexadecimal',\n\t\t\t\tselfDefending: true,\n\t\t\t\tsideEffects: true,\n\t\t\t\tsplitStrings: true,\n\t\t\t\tstringArray: true,\n\t\t\t\tstringArrayThreshold: 0.75\n\t\t\t}\n\t\t}),\n\t]\n}","lang":"typescript","description":"This quickstart demonstrates how to apply obfuscation to a Rollup bundle using the `rollup-plugin-obfuscator`. It shows the basic plugin setup and includes common `javascript-obfuscator` options for a strong obfuscation."},"warnings":[{"fix":"Run `npm install --save-dev rollup-plugin-obfuscator javascript-obfuscator` or `yarn add --dev rollup-plugin-obfuscator javascript-obfuscator`.","message":"This plugin requires `javascript-obfuscator` to be installed separately as a peer dependency. Forgetting to install it will lead to runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review your `include` and `exclude` arrays, especially if you observe unexpected obfuscation or non-obfuscation. The default `exclude: ['node_modules/**']` is usually sufficient, but might need adjustment for monorepos or specific build setups.","message":"When `global` option is `false` (default), obfuscation is applied per-file. This means `include` and `exclude` options determine which individual files are processed. Ensure these patterns correctly target your source code and avoid external dependencies.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Start with milder obfuscation options and incrementally increase complexity. Rigorously test your application's functionality in a production-like environment after obfuscation. Consult the `javascript-obfuscator` documentation for details on each option.","message":"Overly aggressive `javascript-obfuscator` settings can break your application, especially with complex frameworks or dynamic code evaluations. Test thoroughly after applying obfuscation.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Install `javascript-obfuscator` alongside the plugin: `npm install --save-dev javascript-obfuscator`.","cause":"The `javascript-obfuscator` package, a peer dependency, has not been installed.","error":"Error: Cannot find module 'javascript-obfuscator'"},{"fix":"Ensure `javascript-obfuscator` is installed and the plugin configuration is syntactically correct, particularly the `options` object. Check your Rollup configuration for correct plugin array syntax.","cause":"Often indicates an issue where the plugin factory didn't return a valid plugin object or `javascript-obfuscator` wasn't correctly loaded.","error":"TypeError: Cannot read properties of undefined (reading 'transform')"},{"fix":"Verify that the `options` property within the plugin configuration is a valid object, e.g., `obfuscator({ options: { /* ... */ } })`.","cause":"The `options` property passed to `rollup-plugin-obfuscator` is not a plain JavaScript object or is missing.","error":"Rollup 'transform' hook (plugin rollup-plugin-obfuscator) failed with error: Error: Options must be an object!"}],"ecosystem":"npm"}