{"id":25379,"library":"esbuild-plugin-obfuscator","title":"esbuild-plugin-obfuscator","description":"An esbuild plugin that integrates javascript-obfuscator to selectively obfuscate JavaScript files during the build process. Current stable version is 1.4.0, with minor releases on a monthly cadence. Key differentiators: micromatch-based file filtering, optional full output obfuscation, source map support for debugging obfuscated code, and TypeScript type definitions. Alternatives include other esbuild obfuscator plugins like esbuild-obfuscator, but this plugin offers more granular control via filter patterns.","status":"active","version":"1.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/MatteoGheza/esbuild-plugin-obfuscator","tags":["javascript","esbuild","javascript-obfuscator","plugin","obfuscation","typescript"],"install":[{"cmd":"npm install esbuild-plugin-obfuscator","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-obfuscator","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-obfuscator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin interacts with esbuild's build API","package":"esbuild","optional":false},{"reason":"Core obfuscation engine","package":"javascript-obfuscator","optional":false},{"reason":"Used for file filtering patterns","package":"micromatch","optional":false}],"imports":[{"note":"Named export, not default. This is the only export.","wrong":"import ObfuscatorPlugin from 'esbuild-plugin-obfuscator'","symbol":"ObfuscatorPlugin","correct":"import { ObfuscatorPlugin } from 'esbuild-plugin-obfuscator'"},{"note":"Use destructuring for CommonJS; the module exports a named object.","wrong":"const ObfuscatorPlugin = require('esbuild-plugin-obfuscator')","symbol":"require('esbuild-plugin-obfuscator')","correct":"const { ObfuscatorPlugin } = require('esbuild-plugin-obfuscator')"},{"note":"TypeScript type; available since v1.2.5 for custom options typing.","wrong":"","symbol":"ObfuscatorPluginOptions","correct":"import type { ObfuscatorPluginOptions } from 'esbuild-plugin-obfuscator'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport { ObfuscatorPlugin } from 'esbuild-plugin-obfuscator';\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    ObfuscatorPlugin({\n      filter: ['**/sensitive.js'],\n      compact: true,\n      controlFlowFlattening: true,\n    }),\n  ],\n});\nconsole.log('Build complete with selective obfuscation');","lang":"typescript","description":"Demonstrates selective obfuscation of files matching '**/sensitive.js' using micromatch filter, with basic obfuscator options."},"warnings":[{"fix":"Provide a filter array with patterns (e.g., ['**/**.js']) to obfuscate all files, or use shouldObfuscateOutput: true for full output obfuscation.","message":"The 'filter' option expects micromatch patterns and defaults to an empty array, meaning no files are obfuscated unless explicitly specified.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure esbuild is configured with sourcemap: true or inline source maps before using source map features.","message":"In v1.3.0, source map support was added; enabling source maps in esbuild (sourcemap: true) is required to generate source maps for obfuscated code.","severity":"breaking","affected_versions":">=1.3.0"},{"fix":"Avoid duplicating obfuscator options: either use top-level keys or the 'options' object, not both.","message":"Options passed directly to the plugin (like 'compact') are not deprecated but will be overridden if the same key appears in the 'options' object. The plugin merges top-level keys with 'options'.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Only use ignoreRequireImports: true if you have static require imports that should not be obfuscated.","message":"The 'ignoreRequireImports' option may cause unexpected behavior if your code uses dynamic require statements; it only prevents obfuscation of require strings that are static.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use minimal obfuscator options (e.g., { compact: true, controlFlowFlattening: false }) for production builds.","message":"Obfuscating code can significantly increase bundle size and reduce performance; javascript-obfuscator's default settings are heavy.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install esbuild-plugin-obfuscator --save-dev' and ensure no typos in import.","cause":"Missing package installation or incorrect import path.","error":"Error: Cannot find module 'esbuild-plugin-obfuscator'"},{"fix":"Change 'import ObfuscatorPlugin from ...' to 'import { ObfuscatorPlugin } from ...'","cause":"Using default import instead of named import.","error":"TypeError: ObfuscatorPlugin is not a function"},{"fix":"Run 'npm install javascript-obfuscator' (should be auto-installed as peer dependency).","cause":"javascript-obfuscator is not installed as a dependency.","error":"Error: Cannot find module 'javascript-obfuscator'"},{"fix":"Verify the filter patterns (e.g., ['**/*.js']) and ensure entry points include matching files.","cause":"The micromatch patterns in 'filter' do not match any files in the build.","error":"Error: No files matched the given filter patterns"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}