{"id":24799216,"url":"https://github.com/matteogheza/esbuild-plugin-obfuscator","last_synced_at":"2025-10-13T00:31:20.862Z","repository":{"id":257657247,"uuid":"859002206","full_name":"MatteoGheza/esbuild-plugin-obfuscator","owner":"MatteoGheza","description":"An esbuild plugin that obfuscates JavaScript using javascript-obfuscator.","archived":false,"fork":false,"pushed_at":"2025-01-26T22:38:41.000Z","size":68,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T23:13:04.952Z","etag":null,"topics":["esbuild","esbuild-plugin","esbuild-plugins","nodejs","obfuscation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/esbuild-plugin-obfuscator","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatteoGheza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-17T22:53:00.000Z","updated_at":"2025-01-26T22:37:42.000Z","dependencies_parsed_at":"2024-09-18T00:34:36.774Z","dependency_job_id":"e0f872e5-7586-4d35-90dd-5b2a887daf08","html_url":"https://github.com/MatteoGheza/esbuild-plugin-obfuscator","commit_stats":null,"previous_names":["matteogheza/esbuild-plugin-obfuscator"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGheza%2Fesbuild-plugin-obfuscator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGheza%2Fesbuild-plugin-obfuscator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGheza%2Fesbuild-plugin-obfuscator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGheza%2Fesbuild-plugin-obfuscator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatteoGheza","download_url":"https://codeload.github.com/MatteoGheza/esbuild-plugin-obfuscator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236284614,"owners_count":19124147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esbuild","esbuild-plugin","esbuild-plugins","nodejs","obfuscation"],"created_at":"2025-01-30T02:17:28.451Z","updated_at":"2025-10-13T00:31:20.857Z","avatar_url":"https://github.com/MatteoGheza.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esbuild-plugin-obfuscator\n\nA plugin for [esbuild](https://esbuild.github.io/) that obfuscates JavaScript using [javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator). This plugin allows developers to selectively obfuscate JavaScript files during the build process, enhancing security by making the code more difficult to read and understand.\n\n## Installation\n\nInstall the plugin with npm:\n\n```bash\nnpm install esbuild-plugin-obfuscator --save-dev\n```\n\n## Usage\n\nTo use the `esbuild-plugin-obfuscator`, import it in your build script and configure it according to your needs. Below is an example of how to set up the plugin with `esbuild`:\n\n### Example\n\n```javascript\nimport esbuild from 'esbuild';\nimport { ObfuscatorPlugin } from 'esbuild-plugin-obfuscator';\n\n// Run esbuild with the obfuscator plugin and micromatch file filtering\nesbuild.build({\n  entryPoints: ['src/main.js'], // Entry files to build\n  bundle: true,\n  outfile: 'dist/output.js', // Output file\n  plugins: [\n    ObfuscatorPlugin({\n      compact: true, // Obfuscator options\n      controlFlowFlattening: true,\n      filter: ['**/sanitize.js'], // Obfuscate 'sanitize.js' only\n    }),\n  ],\n}).then(() =\u003e {\n  console.log('Build complete with selective obfuscation');\n}).catch(() =\u003e process.exit(1));\n```\n\n### Options\n\nThe `ObfuscatorPlugin` accepts the following options:\n\n- **filter** (`Array\u003cstring\u003e`): A list of micromatch patterns that specify which files should be obfuscated. Default is an empty array `[]`.\n\n- **shouldObfuscateOutput** (`boolean`): If set to `true`, the plugin will obfuscate all output files after the build process is completed. Default is `false`.\n\n- **shouldWriteOutputSourceMap** (`boolean`): If set to `true`, writes the output source map files when obfuscating the final output. This option is only relevant if `shouldObfuscateOutput` is true. Default is `false`.\n\n- **ignoreRequireImports** (`boolean`): If set to `true`, it prevents obfuscation of `require` imports. Could be helpful in some cases when for some reason runtime environment requires these imports with static strings only.\n\n- **options** (`Object`): Additional options for the `javascript-obfuscator`. This can include various configurations available in [javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator#options).\n\n### Source Maps Support\n\nThe plugin automatically generates source maps for obfuscated code to help with debugging:\n\n- **During transform phase**: Source maps are automatically generated and included in esbuild's source map chain, allowing you to debug obfuscated code back to the original source.\n- **During output phase**: When using `shouldObfuscateOutput: true`, you can enable `shouldWriteOutputSourceMap: true` to write separate `.map` files alongside the obfuscated output files.\n\n### Example with Output Obfuscation and Source Maps\n\nYou can also configure the plugin to obfuscate the output files with source map generation:\n\n```javascript\nesbuild.build({\n  entryPoints: ['src/main.js'],\n  bundle: true,\n  outfile: 'dist/output.js',\n  sourcemap: true, // Enable esbuild source maps\n  plugins: [\n    ObfuscatorPlugin({\n      shouldObfuscateOutput: true, // Obfuscate all output files\n      shouldWriteOutputSourceMap: true, // Generate .map files for obfuscated output\n      compact: true,\n      controlFlowFlattening: true,\n    }),\n  ],\n}).then(() =\u003e {\n  console.log('Build complete with output obfuscation and source maps');\n}).catch(() =\u003e process.exit(1));\n```\n\n### Example with Transform-time Obfuscation and Source Maps\n\nFor transform-time obfuscation, source maps are automatically integrated into esbuild's source map chain:\n\n```javascript\nesbuild.build({\n  entryPoints: ['src/main.js'],\n  bundle: true,\n  outfile: 'dist/output.js',\n  sourcemap: true, // Enable esbuild source maps\n  plugins: [\n    ObfuscatorPlugin({\n      filter: ['**/sanitize.js'], // Obfuscate specific files\n      compact: true,\n      controlFlowFlattening: true,\n    }),\n  ],\n}).then(() =\u003e {\n  console.log('Build complete with selective obfuscation and integrated source maps');\n}).catch(() =\u003e process.exit(1));\n```\n\n## File Filtering\n\nThe plugin uses [micromatch](https://github.com/micromatch/micromatch) to filter which files are obfuscated. You can use patterns like:\n\n- `**/*.js` to match all JavaScript files.\n- `**/folder/*.js` to match JavaScript files in a specific folder.\n- `!**/exclude/**` to exclude files from being obfuscated.\n\n### Example of Filtering\n\n```javascript\nObfuscatorPlugin({\n  filter: ['**/*.js', '!**/exclude/**'],\n});\n```\n\n## Contributing\n\nContributions are welcome! If you would like to contribute to this project, please fork the repository and submit a pull request. Ensure that your code follows the project's style and is well-documented.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n## Acknowledgments\n\n- [esbuild](https://esbuild.github.io/) for providing a fast and efficient JavaScript bundler.\n- [javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator) for powerful obfuscation capabilities.\n- [esbuild-extra](https://github.com/aleclarson/esbuild-extra) - for extending Esbuild plugins abilities, especially for the `onTransform` and `onEnd` hooks.\n\n## Support\n\nIf you encounter any issues or have questions, feel free to open an issue on the [GitHub repository](https://github.com/MatteoGheza/esbuild-plugin-obfuscator/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatteogheza%2Fesbuild-plugin-obfuscator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatteogheza%2Fesbuild-plugin-obfuscator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatteogheza%2Fesbuild-plugin-obfuscator/lists"}