Registry / devops / esbuild-obf

esbuild-obf

JSON →
library1.0.5jsnpmunverified

A plugin for esbuild that obfuscates JavaScript using javascript-obfuscator with selective file filtering. Current version is 1.0.5. It enables developers to obfuscate specific files during the build process or optionally obfuscate all output files. The plugin uses micromatch patterns for file selection and integrates seamlessly with esbuild's plugin system. Key differentiators include filtering, output obfuscation, and ignoreRequireImports option. It is actively maintained.

npm install esbuild-obf
INSTALL
IMPORT
SIG · ESBUILD-OBF
E
esbuild-obf
devopsjavascriptv1.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

ObfuscatorPlugin
import { ObfuscatorPlugin } from 'esbuild-plugin-obfuscator';
import ObfuscatorPlugin from 'esbuild-plugin-obfuscator';
Named export, not default.
ObfuscatorPlugin (CommonJS)
const { ObfuscatorPlugin } = require('esbuild-plugin-obfuscator');
CommonJS require pattern.
Plugin (type)
import type { Plugin } from 'esbuild';
For TypeScript, no type export from the plugin itself.

Demonstrates basic usage with selective file obfuscation using micromatch patterns.

import esbuild from 'esbuild'; import { ObfuscatorPlugin } from 'esbuild-plugin-obfuscator'; // Build with selective obfuscation of files matching pattern '**/sanitize.js' esbuild.build({ entryPoints: ['src/main.js'], bundle: true, outfile: 'dist/output.js', plugins: [ ObfuscatorPlugin({ compact: true, controlFlowFlattening: true, filter: ['**/sanitize.js'], }), ], }).then(() => { console.log('Build complete with selective obfuscation'); }).catch(() => process.exit(1));
Debug
Known issues
gotchaIf filter option is empty, no files will be obfuscated unless shouldObfuscateOutput is true.
fix
Set filter to ['**/*.js'] or use shouldObfuscateOutput: true.
affects: >=1.0.0
gotchaObfuscation can significantly increase bundle size and execution time.
fix
Use selective filtering to minimize impact.
affects: >=1.0.0
gotchaignoreRequireImports may break code that relies on dynamic require statements.
fix
Test thoroughly if enabling this option.
affects: >=1.0.0
gotchashouldObfuscateOutput obfuscates the entire output file, potentially breaking external references.
fix
Use with caution; prefer selective filtering.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: ObfuscatorPlugin is not a function
Incorrect import: using default import instead of named.
fix
Use `import { ObfuscatorPlugin } from 'esbuild-plugin-obfuscator';`
Error: Cannot find module 'javascript-obfuscator'
javascript-obfuscator is a peer dependency but not installed.
fix
Run `npm install javascript-obfuscator --save-dev`
No files obfuscated even with filter set
Filter patterns do not match any files; micromatch pattern issue.
fix
Verify patterns using micromatch test. Ensure correct relative path from esbuild context.
Build hangs or memory runs out with large bundles
Obfuscation is CPU/memory intensive. Large files cause OOM.
fix
Use selective filtering or disable obfuscation on large files.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
javascript-obfuscatorrequiredcore obfuscation engine
micromatchrequiredfile pattern matching for filtering
Agent activity
17 hits · last 30 days
node
16
Amazon
1
Resources
esbuild-obf — npm install esbuild-obf · libregistry