Open source Node CLI

Unpack JavaScript bundles into real, runnable modules

Packscope turns a single shipped bundle — from webpack, rspack, rollup, esbuild, or Vite — into a navigable project tree that you can read, grep, edit, and run.

terminal
$ npx packscope ./dist/app.js ./out

# webpack/rspack output
out/
├── header.js
├── webpack-runtime.js
├── runtime.js
├── index.js
├── modules/<id>.js
├── manifest.json
├── rebuild.js
└── package.json

$ node out/index.js --version
2.106.4

Features

What Packscope gives you

One file per module

Each webpack/rspack module is written to modules/<id>.js. ES-module chunks go to chunks/ and original sources to sources/.

Executable by default

The loader reconstructs the original bundle shape using the real UMD header and webpack runtime, so the unpacked tree runs identically.

Edit & rebuild

Modify any module, then run node out/rebuild.js bundle-edited.js to regenerate a single runnable bundle.

Unpack from URLs

Pass an http:// or https:// URL. Packscope downloads the bundle, resolves chunks, and rewrites imports to local paths.

Manifest & dependency graph

manifest.json contains IDs, sizes, dependency edges, inferred names, and downloaded assets for further analysis.

Optional beautify & rename

Use --beautify and --rename for readable output. Defaults keep original slices for guaranteed execution.

Internals

How it works

1

Parse the bundle

Acorn locates the webpack modules dictionary and maps every module boundary.

2

Extract faithful bodies

Each module body is sliced verbatim from the bundle. No AST rewrite means no statement-order surprises.

3

Reconstruct the loader

runtime.js rebuilds the original expression: header + delegator-filled modules + original runtime.

4

Wire externals

Externals like chokidar are detected from shim patterns and wired through the same UMD path as the original.

Quick Start

Usage

Install

npm install

Unpack a local bundle

npx packscope ./dist/app.js ./out

Unpack from a URL

npx packscope https://example.com/app.js ./out

Run the unpacked tree

node out/index.js --version
node out/index.js --help

Options

  • --beautify — pretty-print output (best-effort)
  • --decompose — extract classes / services / wrappers for navigation (ES modules)
  • --rename — rename wrapper params to module/exports/require
  • --fetch-assets / --no-fetch-assets — control source-map / asset downloads
  • --entry <N> — force entry module id

Rebuild after editing

echo "// patched" >> out/modules/92367.js
node out/rebuild.js bundle-patched.js
node bundle-patched.js --version

Ready to inspect your bundle?

Clone the repo and unpack your first mono bundle in seconds.