Registry / devops / rollup-obfuscator

rollup-obfuscator

JSON →
library4.1.1jsnpmunverified

A Rollup and Vite plugin for obfuscating JavaScript bundles using javascript-obfuscator. Current stable version is 4.1.1, released in September 2024. It supports Rollup v2, v3, and v4, and Vite build-time only. Key differentiators: it works as an end-of-pipeline plugin, filters files by pattern, and sets sensible defaults (sourceMap: true, stringArray: false) to reduce breakage. Requires Node 16+ and javascript-obfuscator v4 as a peer dependency. The plugin is actively maintained with regular releases addressing bugs and compatibility.

npm install rollup-obfuscator
INSTALL
IMPORT
SIG · ROLLUP-OBFUSCATOR
R
rollup-obfuscator
devopsjavascriptv4.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

obfuscator
import { obfuscator } from 'rollup-obfuscator'
const obfuscator = require('rollup-obfuscator')
Named export only; no default export. Requires ESM.
obfuscator default
import { obfuscator } from 'rollup-obfuscator'
import obfuscator from 'rollup-obfuscator'
Default import is not available. Must use named import.
Type definitions
import type { ObfuscatorOptions } from 'rollup-obfuscator'
TypeScript types are bundled; ObfuscatorOptions type is exported for plugin config.

Basic Rollup configuration with obfuscator plugin at the end of plugins array, demonstrating import and usage.

// rollup.config.js import { obfuscator } from 'rollup-obfuscator'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ // other plugins... obfuscator({ // javascript-obfuscator options (optional) compact: true, controlFlowFlattening: false, // plugin-specific options include: ['**/*.js'], exclude: ['node_modules/**'] }) ] };
Debug
Known issues
breakingv4 removed options.global. The option no longer exists.
fix
Remove options.global from your plugin call. The default behavior now matches v3's global: false.
affects: >=4.0.0
breakingv4 requires Node 16+. Older Node versions are not supported.
fix
Upgrade Node to v16 or later.
affects: >=4.0.0
breakingv4 changed default obfuscator options: sourceMap now defaults to true, stringArray defaults to false.
fix
If you rely on the old defaults, explicitly set sourceMap: false and stringArray: true in options.
affects: >=4.0.0
gotchaPlugin must be placed at the end of the plugins array to ensure other transforms run before obfuscation.
fix
Always list obfuscator() as the last plugin.
affects: >=0.0.0
gotchajavascript-obfuscator is a peer dependency; you must install it separately or the plugin will fail.
fix
Run 'npm install javascript-obfuscator --save-dev'.
affects: >=4.0.0
deprecatedIn v2, the library used a default export; v3+ switched to named export 'obfuscator'.
fix
Use import { obfuscator } from 'rollup-obfuscator' instead of import obfuscator from 'rollup-obfuscator'.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'javascript-obfuscator'
Missing peer dependency javascript-obfuscator
fix
npm install javascript-obfuscator --save-dev
TypeError: obfuscator is not a function
Using default import instead of named import (v3+).
fix
Change to: import { obfuscator } from 'rollup-obfuscator';
Error: Rollup plugin 'rollup-obfuscator' must be at the end of the plugins array
Plugin placed before other plugins that generate output.
fix
Move the obfuscator() call to the last position in the plugins array.
Upgrade
Version history
4.1.1latest on npm
Audit
Dependencies
javascript-obfuscatorrequiredCore obfuscation library; peer dependency v4.x
Agent activity
9 hits · last 30 days
node
6
Bingbot
1
Resources
rollup-obfuscator — npm install rollup-obfuscator · libregistry