Skip to main content
Option: transforms.pack

What it changes

Serializes the program and executes it through a generated Function constructor.
pack runs the generated string as a Function body. import.meta and top-level await are syntax errors there. A top-level arguments refers to the generated function. pack rejects export statements before producing output.

Before and after

Configuration

Run this transform by setting transforms.pack to true or an options object:
obfuscate.mjs
Pass { escapeStrict, skipGlobals, stringGeneratorMode } instead of true. escapeStrict removes strict mode from the generated function. skipGlobals defaults to true, which leaves standard globals as direct references. Set it to false to route every free name through accessors. An array replaces the default list. Every listed name must be visible inside a generated Function.

View the implementation

Open the TypeScript implementation on GitHub.

Read the behavior tests

Review behavior checks and cases this transform leaves alone.
Last modified on August 29, 2026