{"id":25801,"library":"js-virtualizer","title":"js-virtualizer","description":"A proof-of-concept JavaScript obfuscation tool that converts individual functions into bytecode executed by a custom virtual machine (VM) written in JavaScript. Version 1.0.2 is the current and only release. The transpiler converts functions marked with `// @virtualize` into opcodes for the VM. Key differentiators: unlike traditional obfuscators that rename/transform AST, this executes code in an interpreted VM, making reverse engineering significantly harder. Not intended for whole programs due to performance overhead; targets server-side Node.js, not browsers. Development appears stalled (no updates since initial release).","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/aesthetic0001/js-virtualizer","tags":["javascript","obfuscation","virtualization","transpiler"],"install":[{"cmd":"npm install js-virtualizer","lang":"bash","label":"npm"},{"cmd":"yarn add js-virtualizer","lang":"bash","label":"yarn"},{"cmd":"pnpm add js-virtualizer","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Both ESM and CJS are supported. The package exports transpile as a named export.","wrong":"const transpile = require('js-virtualizer').transpile","symbol":"transpile","correct":"import { transpile } from 'js-virtualizer'"},{"note":"VM is the virtual machine class. It is exported as a named export but rarely used directly – transpile() generates code that uses VM internally.","wrong":"const jsVirtualizer = require('js-virtualizer'); const VM = jsVirtualizer.VM;","symbol":"VM","correct":"import { VM } from 'js-virtualizer'"},{"note":"execute function is not part of the public API. It is an internal detail. Use transpile() instead.","wrong":null,"symbol":"execute","correct":"import { execute } from 'js-virtualizer'"}],"quickstart":{"code":"const { transpile } = require('js-virtualizer');\n\nasync function main() {\n  const code = `\n    // @virtualize\n    function add(a, b) {\n      return a + b;\n    }\n    add(1, 2);\n  `;\n\n  const result = await transpile(code, {\n    fileName: 'example',\n    writeOutput: false,\n    vmOutputPath: './vm_output.js',\n    transpiledOutputPath: './output.js',\n    passes: ['RemoveUnused', 'ObfuscateVM', 'ObfuscateTranspiled']\n  });\n\n  console.log('Transpiled code:', result.code);\n}\n\nmain().catch(console.error);","lang":"javascript","description":"Demonstrates transpiling a simple virtualized function with multiple passes, writing output to files, and handling configuration options."},"warnings":[{"fix":"Ensure all functions that should be virtualized have the exact comment // @virtualize on the line immediately above the function declaration.","message":"Only functions marked with // @virtualize comment are transpiled. Other code is left as-is, which can lead to mixed code that may not execute correctly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Only use // @virtualize on small, critical functions. Test performance impact before production.","message":"Virtualizing an entire program or large functions will cause severe performance degradation. The VM is designed for small, isolated functions only.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Avoid using concurrent async functions inside virtualized code. Use sequential awaits or callbacks.","message":"Async functions running concurrently are not supported. The VM executes asynchronous operations sequentially.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If using in a browser, replace require() calls in vm_dist.js with browser-compatible imports (e.g., ES modules or window globals).","message":"The package is intended for Node.js server-side only. It uses require() internally and has not been tested in browsers.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Edit src/vm_dist.js to rename opcode identifiers and apply obfuscation to the VM itself.","message":"The default VM file (vm_dist.js) includes opcode names in plain text, making reverse engineering easier. It is recommended to modify and obfuscate this file before production use.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For production obfuscation, consider alternatives like jscrambler, javascript-obfuscator, or commercial solutions. Maintain your own fork if needed.","message":"This project appears to be a proof-of-concept with no updates since initial release. The API may not be stable.","severity":"deprecated","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":"Add // @virtualize as a comment line immediately before the function declaration you want to virtualize.","cause":"No functions were marked with the required comment, so the transpiler produces no output.","error":"Error: The code does not contain any // @virtualize comments."},{"fix":"Use await or .then() to handle the asynchronous transpile() call.","cause":"Running transpile() without await may return a Promise object instead of the result object.","error":"TypeError: Cannot read properties of undefined (reading 'code')"},{"fix":"Refactor the virtualized function to avoid relying on 'this'. Use explicit parameters or bind the context outside.","cause":"The VM does not support a function accessing its own 'this' property. Arrow functions or methods may fail.","error":"Error: The virtualized function uses 'this' incorrectly."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}