Registry / devops / webpack-obfuscator

webpack-obfuscator

JSON →
library3.6.1jsnpmunverified

webpack-obfuscator is a JavaScript Obfuscator plugin and loader designed specifically for Webpack 5 and above. It integrates the robust `javascript-obfuscator` library into the Webpack build process, allowing developers to protect their JavaScript code by making it harder to read and reverse-engineer. The current stable version is 3.6.1. Releases appear to be frequent, focusing on dependency updates and minor enhancements, indicating an active maintenance schedule. A key differentiator is its seamless integration as both a Webpack plugin and a loader, offering flexibility in how obfuscation is applied, including the ability to exclude specific bundles or files. It also supports the obfuscator.io Pro API for advanced, cloud-based obfuscation techniques, requiring `javascript-obfuscator` version 5.0.0 or higher for this feature.

npm install webpack-obfuscator
INSTALL
IMPORT
SIG · WEBPACK-OBFUSCATOR
W
webpack-obfuscator
devopsjavascriptv3.6.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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

WebpackObfuscator
import WebpackObfuscator from 'webpack-obfuscator';
const WebpackObfuscator = require('webpack-obfuscator');
While the README shows `require()`, for modern Webpack configurations and TypeScript, ESM `import` is preferred. The package ships with types.
WebpackObfuscator.loader
import WebpackObfuscator from 'webpack-obfuscator'; // then use WebpackObfuscator.loader
import { loader } from 'webpack-obfuscator'; // The loader is a static property on the default export.
The loader reference is a property of the default export, not a named export.
WebpackObfuscator Plugin Usage (TypeScript)
import WebpackObfuscator from 'webpack-obfuscator'; const config: Configuration = { // ... plugins: [ new WebpackObfuscator({ rotateStringArray: true }, ['excluded_bundle_name.js']) ] };
When using TypeScript, import `WebpackObfuscator` as a default import. Webpack configuration types can be imported from `webpack`.

Demonstrates a basic Webpack configuration applying `webpack-obfuscator` as both a plugin (for global bundle obfuscation with exclusions) and a loader (for individual file obfuscation before other loaders, using `enforce: 'post'`).

const path = require('path'); const WebpackObfuscator = require('webpack-obfuscator'); module.exports = { mode: 'production', entry: { 'main': './src/index.js' }, output: { path: path.resolve(__dirname, 'dist'), filename: '[name].js' }, plugins: [ new WebpackObfuscator({ rotateStringArray: true, stringArrayThreshold: 0.75 }, ['main.js']) ], module: { rules: [ { test: /\.js$/, exclude: /node_modules/, enforce: 'post', use: { loader: WebpackObfuscator.loader, options: { compact: true } } } ] } };
Debug
Known issues
breakingVersion 3.0.0 and higher of `webpack-obfuscator` are only compatible with Webpack 5 and above. Older Webpack versions (e.g., Webpack 4) require `webpack-obfuscator` version 2.x.
fix
Upgrade to Webpack 5 or higher, or downgrade `webpack-obfuscator` to a 2.x release if tied to Webpack 4.
affects: >=3.0.0
breakingStarting with version 3.0.0, `javascript-obfuscator` is a peer dependency and must be installed explicitly alongside `webpack-obfuscator`. Previously, it was a direct dependency.
fix
Ensure `javascript-obfuscator` is installed: `npm install --save-dev javascript-obfuscator`.
affects: >=3.0.0
gotchaUsing the Pro API for cloud-based obfuscation requires `javascript-obfuscator` version 5.0.0 or higher. Ensure your `javascript-obfuscator` peer dependency meets this requirement if you intend to use Pro API features.
fix
Verify `javascript-obfuscator` version in `package.json` and update if necessary (`npm install javascript-obfuscator@latest`).
affects: >=3.0.0
gotchaWhen using the loader, it's recommended to add `enforce: 'post'` to your webpack rule. This ensures the obfuscator loader runs after all other normal loaders, preventing potential conflicts or issues where other loaders might interfere with the obfuscation process.
fix
Add `enforce: 'post'` to the loader rule in your webpack configuration: `{ test: /\.js$/, enforce: 'post', use: { loader: WebpackObfuscator.loader, ... } }`.
affects: >=3.0.0
gotchaThe `excludes` option for the plugin takes bundle names (output file names), not source file names. When using `[name].js` in webpack's output, these are the names to exclude. For the loader, `exclude` takes source file paths.
fix
For the plugin, ensure `excludes` array matches your compiled bundle names (e.g., `['my-bundle.js']`). For the loader, use `path.resolve(__dirname, 'src/excluded-file.js')`.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: WebpackObfuscator is not a constructor
Incorrect import statement (e.g., using named import for a default export) or trying to `require` a pure ESM package.
fix
For CommonJS, `const WebpackObfuscator = require('webpack-obfuscator');` is shown in the README. For ESM, use `import WebpackObfuscator from 'webpack-obfuscator';`
Error: Cannot find module 'javascript-obfuscator'
The `javascript-obfuscator` package, a peer dependency, is not installed.
fix
Install the peer dependency: `npm install --save-dev javascript-obfuscator`.
Error: The 'options' property is only allowed for 'plugins' with a 'tap' hook
Attempting to pass loader options directly to the `WebpackObfuscator` plugin constructor without nesting them under `options` for the loader itself, or mistaking plugin usage for loader usage.
fix
When using `WebpackObfuscator.loader`, options should be nested under `options` in the `use` object: `{ use: { loader: WebpackObfuscator.loader, options: { rotateStringArray: true } } }`.
Webpack compilation fails or code is not obfuscated as expected (Webpack 4 user)
Using `webpack-obfuscator` v3.x with Webpack 4, which is incompatible.
fix
Downgrade `webpack-obfuscator` to a 2.x version (e.g., `npm install webpack-obfuscator@^2.0.0 --save-dev`) or upgrade your project to Webpack 5.
Upgrade
Version history
3.6.1latest on npm
Audit
Dependencies
javascript-obfuscatorrequiredCore obfuscation engine. Must be installed separately as a peer dependency.
webpackrequiredRequired for Webpack 5 integration. This plugin is not compatible with Webpack 4 or older.
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
webpack-obfuscator — npm install webpack-obfuscator · libregistry