npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@afterpack/wasm

v1.2.2

Published

The AfterPack JavaScript obfuscator as WebAssembly, for Cloudflare Workers and Node

Readme

@afterpack/wasm

The AfterPack JavaScript obfuscator as WebAssembly. Use it where a native Node addon can't load, for example to obfuscate JavaScript in a Cloudflare Worker. It also runs in Node.

For a normal Node build, use @afterpack/core. It has the same obfuscate and obfuscateAll API, runs natively and keeps the work off the main thread. Want to try AfterPack first? The playground obfuscates JavaScript in your browser.

Install

npm install @afterpack/wasm

In a Cloudflare Worker

No init step, no nodejs_compat flag and no extra wrangler rules.

import { obfuscate } from "@afterpack/wasm";

export default {
  async fetch(request) {
    const source = await request.text();
    const result = await obfuscate({ path: "app.js", source }, { preset: "hard" });
    return new Response(result.bytes, {
      headers: { "content-type": "application/javascript" },
    });
  },
};

Pro from a Worker

Add your Pro key to the same call. The build then runs on AfterPack's cloud with Pro features, and files too big for a Worker move to containers automatically. The Pro build never ships into your Worker.

export default {
  async fetch(request, env) {
    const source = await request.text();
    const result = await obfuscate(
      { path: "app.js", source },
      { preset: "hard", key: env.AFTERPACK_KEY }, // your key, stored as a Worker secret
    );
    return new Response(result.bytes, {
      headers: { "content-type": "application/javascript" },
    });
  },
};

Tip: each Pro call is a metered build, so cache the result for a rotation window. Key the Cache API by the asset and the window, and each asset is built once per window instead of on every request.

The full guide: obfuscate JavaScript in a Cloudflare Worker.

In Node

Same import. The package picks its Node entry automatically.

import { obfuscate, obfuscateAll, version } from "@afterpack/wasm";

const result = await obfuscate('console.log("hello")', { preset: "hard" });
result.code;  // the obfuscated source
result.bytes; // the same output as bytes, ready to write

// Several files at once. Results come back in input order.
const results = await obfuscateAll([
  { path: "dist/app.js", source: appSource },
  { path: "dist/vendor.js", source: vendorSource, sourceMap: vendorMap },
]);

await version(); // "0.2.1"

obfuscate accepts a string, a Uint8Array, or a file object { path, source, sourceMap, sourceType }, where sourceMap is the file's existing map to chain and sourceType ("auto", "module" or "script") overrides the build's for that file. Each result has code, bytes, sourceMap and diagnostics. The second argument is the config. See the configuration reference and the presets.

A tool that wraps AfterPack can name itself to the cloud in an optional third argument, obfuscate(source, config, { client: "my-tool/1.0.0" }). It never changes the output.

Errors

If a build can't ship safely, the call throws an ObfuscationError with the engine's diagnostics. That covers an invalid config, a blocking diagnostic, or output that would go out unprotected.

import { obfuscate, ObfuscationError } from "@afterpack/wasm";

try {
  await obfuscate(source);
} catch (err) {
  if (err instanceof ObfuscationError) console.error(err.diagnostics);
  throw err;
}

Pro

Without a key, all of Free runs inside your Worker or Node process, with every preset. Add a Pro key ({ key: env.AFTERPACK_KEY }) and the same call runs the build in AfterPack's cloud instead. Pro adds per-file and per-region direction through directives, stores each build's Protection Map, and shows your builds in the dashboard. It also offers two opt-in hardening settings, transforms.selfIntegrity and transforms.comparisonHardening, both off by default (details). It does not make any transform stronger, and none of it is part of this package. See deployment modes, AfterPack Pro and pricing.

Size

| Measure | Bytes | | |---|---:|---| | Raw .wasm | 4,642,918 | 4.43 MiB | | Gzipped | 1,301,444 | 1.24 MiB |

This fits Cloudflare's Worker size limit on both the free and paid plans. CPU time is the tighter limit: the free plan allows 10 ms per request, and obfuscating a 185 KB bundle at complexity: 8 takes about 263 ms on an Apple M-series laptop. Plan on Workers Paid for real bundles.

Limits

  • No browser entry. It runs in Workers and Node.
  • Each file is one synchronous engine call that holds the isolate until it finishes. obfuscateAll processes files one at a time.

License

Free for any use, including commercial and CI, with no limits, and the output is yours. You can't redistribute the binary on its own, build a competing obfuscation product or service on it, or reverse engineer it. See the AfterPack Engine License.

Questions and feedback: get in touch. Bug reports: GitHub.