esbuild-obfuscator

raw JSON →
0.0.7 verified Fri May 01 auth: no javascript

esbuild-obfuscator is an esbuild plugin that integrates javascript-obfuscator to obfuscate JavaScript bundles during the build process. Version 0.0.7 is the latest stable release, with an active but early-stage development cadence. It provides a simple plugin interface compatible with esbuild 0.24.x, and ships TypeScript definitions. Unlike manual post-processing, it automates obfuscation within esbuild's pipeline, reducing build complexity. However, it is a thin wrapper with limited configuration options and no built-in source map handling.

error Error: Cannot find module 'esbuild-obfuscator'
cause Package not installed or not resolved correctly (e.g., using require in ESM context).
fix
Install the package: npm install esbuild-obfuscator. Ensure you are using import syntax in an ESM project.
error TypeError: esbuildObfuscator is not a function
cause Named import used instead of default import (e.g., import { esbuildObfuscator } from 'esbuild-obfuscator').
fix
Use default import: import esbuildObfuscator from 'esbuild-obfuscator'.
error Error: The plugin "esbuild-obfuscator" is not compatible with this version of esbuild
cause esbuild version does not satisfy the peer dependency requirement (^0.24.0).
fix
Upgrade esbuild to ^0.24.0 or later.
breaking Peer dependency esbuild ^0.24.0 is required; versions below 0.24.0 are unsupported and may cause runtime errors.
fix Upgrade esbuild to ^0.24.0 or later.
gotcha The plugin exports a default function, not named exports. Attempting to import as { esbuildObfuscator } will result in undefined.
fix Use default import: import esbuildObfuscator from 'esbuild-obfuscator'.
gotcha Obfuscation can significantly increase bundle size and reduce performance. Use with caution in production builds.
fix Consider using obfuscation only for release builds and test thoroughly.
gotcha The plugin does not handle source maps automatically; obfuscated output may break source map integrity.
fix Disable source maps or process separately if needed.
deprecated No known deprecations at this time.
npm install esbuild-obfuscator
yarn add esbuild-obfuscator
pnpm add esbuild-obfuscator

Shows how to use esbuild-obfuscator as an esbuild plugin with basic configuration options.

import esbuild from 'esbuild';
import esbuildObfuscator from 'esbuild-obfuscator';

await esbuild.build({
  entryPoints: ['app.js'],
  bundle: true,
  outfile: 'out.js',
  plugins: [
    esbuildObfuscator({
      compact: true,
      controlFlowFlattening: true
    })
  ]
});