{"_id":"@andrewgross/bun-decompile","_rev":"2-a3844b0aad2789859072bf27639c6193","name":"@andrewgross/bun-decompile","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@andrewgross/bun-decompile","version":"0.1.0","keywords":["bun","decompile","unbundle","extract","reverse-engineering","single-file-executable","macho","elf","pe"],"author":{"name":"Andrew Gross","email":"andrew.w.gross@gmail.com"},"license":"UNLICENSED","_id":"@andrewgross/bun-decompile@0.1.0","maintainers":[{"name":"andrewgross","email":"andrew.w.gross@gmail.com"}],"homepage":"https://github.com/andrewgross/bun-decompile-ag#readme","bugs":{"url":"https://github.com/andrewgross/bun-decompile-ag/issues"},"bin":{"bun-decompile":"dist/cli.js"},"dist":{"shasum":"137af7c9fd1a6dcabf8779aab3a6a44eb030fcc2","tarball":"https://registry.npmjs.org/@andrewgross/bun-decompile/-/bun-decompile-0.1.0.tgz","fileCount":46,"integrity":"sha512-0BC0T1Uxf1hNgTaruP13DrQvt5w44YEZbviWtzdj07OutBVfk5fHvAEQyA/Wdq6B8pwpY9N6qG2UI4nS2d1rnw==","signatures":[{"sig":"MEQCIDcGv/VDa0AfswSvmpwP8N9QgLHr371hfYYgwYNy45zoAiByODT22xTDVN1z2mHMv01ULa/6w1ZMNP20l381XWShng==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":87154},"main":"./dist/lib/index.js","type":"module","types":"./dist/lib/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/lib/index.d.ts","default":"./dist/lib/index.js"},"./package.json":"./package.json"},"gitHead":"31be41b44b6909c09215468a292a0f6d8ab9b6d9","scripts":{"lint":"prettier --check .","test":"bun test","build":"tsc -p tsconfig.build.json","start":"bun src/cli.ts","format":"prettier --write .","prepare":"tsc -p tsconfig.build.json","release":"bun run build && npm publish","test:e2e":"bash src/scripts/e2e-test.sh","typecheck":"tsc --noEmit","debug-binary":"bun src/scripts/debug-binary.ts","build-fixtures":"bash src/scripts/build-fixtures.sh"},"_npmUser":{"name":"andrewgross","email":"andrew.w.gross@gmail.com"},"repository":{"url":"git+https://github.com/andrewgross/bun-decompile-ag.git","type":"git"},"_npmVersion":"11.1.0","description":"Extracts the original transpiled sources from an executable file generated via `bun build --compile`. Supports Bun v0.6.0 through v1.4.x on macOS, Linux, and Windows.","directories":{},"_nodeVersion":"23.8.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.8.1","prettier":"^3.6.2","@types/bun":"^1.2.20","typescript":"^5.9.2","@types/node":"^20","@ianvs/prettier-plugin-sort-imports":"^4.6.2"},"_npmOperationalInternal":{"tmp":"tmp/bun-decompile_0.1.0_1784658692445_0.9188845273132538","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@andrewgross/bun-decompile","version":"0.1.1","description":"Extracts the original transpiled sources from an executable file generated via `bun build --compile`. Supports Bun v0.6.0 through v1.4.x on macOS, Linux, and Windows.","author":{"name":"Andrew Gross","email":"andrew.w.gross@gmail.com"},"license":"UNLICENSED","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/andrewgross/bun-decompile-ag.git"},"bugs":{"url":"https://github.com/andrewgross/bun-decompile-ag/issues"},"homepage":"https://github.com/andrewgross/bun-decompile-ag#readme","keywords":["bun","decompile","unbundle","extract","reverse-engineering","single-file-executable","macho","elf","pe"],"type":"module","main":"./dist/lib/index.js","types":"./dist/lib/index.d.ts","exports":{".":{"types":"./dist/lib/index.d.ts","default":"./dist/lib/index.js"},"./package.json":"./package.json"},"bin":{"bun-decompile":"dist/cli.js"},"engines":{"node":">=18"},"devDependencies":{"@ianvs/prettier-plugin-sort-imports":"^4.6.2","@types/bun":"^1.2.20","@types/node":"^20","prettier":"^3.6.2","tslib":"^2.8.1","typescript":"^5.9.2"},"scripts":{"build":"tsc -p tsconfig.build.json","prepare":"tsc -p tsconfig.build.json","release":"bun run build && npm publish","start":"bun src/cli.ts","test":"bun test","test:e2e":"bash src/scripts/e2e-test.sh","build-fixtures":"bash src/scripts/build-fixtures.sh","debug-binary":"bun src/scripts/debug-binary.ts","typecheck":"tsc --noEmit","lint":"prettier --check .","format":"prettier --write ."},"gitHead":"c27ba57d600ebfd9ec901d1c0255363fe1796862","_id":"@andrewgross/bun-decompile@0.1.1","_nodeVersion":"22.23.1","_npmVersion":"12.0.1","dist":{"integrity":"sha512-DVcywfaGMukmT1ai70n8I1i1SIZLIrhTBPthWGKM2q8/8PopvRZtoQ98hjhLNUdMkCgWH2n2xNwLs4xzemkLeQ==","shasum":"7194dcd9107e5b0928f8c689debabe0a940c6ed4","tarball":"https://registry.npmjs.org/@andrewgross/bun-decompile/-/bun-decompile-0.1.1.tgz","fileCount":46,"unpackedSize":87152,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@andrewgross%2fbun-decompile@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHmmtG+2/S9AdrCd72Z/EJ//09ahrg5ERNATRSZjtK3IAiEA5O7QklhmjSoc8jjMKTC8DfhDQ3FjU7GHZWsLHKvTpBQ="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:36c85b90-d21a-4222-b09f-c0beaa5e37c6"}},"directories":{},"maintainers":[{"name":"andrewgross","email":"andrew.w.gross@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bun-decompile_0.1.1_1784660630511_0.36849767989414883"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-21T18:31:32.189Z","modified":"2026-07-21T19:03:52.959Z","0.1.0":"2026-07-21T18:31:32.590Z","0.1.1":"2026-07-21T19:03:50.647Z"},"bugs":{"url":"https://github.com/andrewgross/bun-decompile-ag/issues"},"author":{"name":"Andrew Gross","email":"andrew.w.gross@gmail.com"},"license":"UNLICENSED","homepage":"https://github.com/andrewgross/bun-decompile-ag#readme","keywords":["bun","decompile","unbundle","extract","reverse-engineering","single-file-executable","macho","elf","pe"],"repository":{"type":"git","url":"git+https://github.com/andrewgross/bun-decompile-ag.git"},"description":"Extracts the original transpiled sources from an executable file generated via `bun build --compile`. Supports Bun v0.6.0 through v1.4.x on macOS, Linux, and Windows.","maintainers":[{"name":"andrewgross","email":"andrew.w.gross@gmail.com"}],"readme":"# bun-decompile\n\nExtracts the original transpiled sources from an executable produced by\n`bun build --compile`.\n\nThis is a maintained fork of [lafkpages/bun-decompile](https://github.com/lafkpages/bun-decompile),\nwhich did the original reverse-engineering of Bun's standalone module graph. See\n[Credits](#credits).\n\n## What it supports\n\nEvery Bun binary layout from v0.6.0 through v1.4.x, across all three desktop\nplatforms. Bun embeds the compiled payload differently depending on version and\ntarget; the extractor detects the container by sniffing magic bytes and\ndispatches accordingly, so you don't need to tell it which one you have.\n\n| Platform | Container                    | Since        |\n| -------- | ---------------------------- | ------------ |\n| macOS    | Mach-O `__BUN/__bun` section | all versions |\n| Linux    | ELF `.bun` section           | ~1.3.10+     |\n| Windows  | PE `.bun` section            | ~1.3.9+      |\n| any      | appended-to-EOF (legacy)     | ≲ 1.2.x      |\n\nFour on-disk metadata formats are handled (V1 through V4), spanning the\n0.6.0-era layout through the 32-byte offset struct introduced in 1.3.0. Bun\n1.4.0 is supported, including its\n[reworked version banner](#a-note-on-bun-140) — extraction itself never depends\non the version string.\n\n## Installation\n\n```sh\nnpm install -g @andrewgross/bun-decompile\n```\n\nOr with Bun:\n\n```sh\nbun add -g @andrewgross/bun-decompile\n```\n\nOr run it without installing:\n\n```sh\nbunx @andrewgross/bun-decompile <binary>\nnpx @andrewgross/bun-decompile <binary>\n```\n\nThe CLI runs on Node 18+ and on Bun. You do **not** need Bun installed to\nextract a Bun binary.\n\n## Usage\n\n```sh\nbun-decompile <input-binary> [options]\n```\n\nThe installed command is `bun-decompile` (shorter than the scoped package name).\n\n```console\n$ bun-decompile ./my-app -o ./extracted\nBun v1.3.9 (cf6cdbbb)\nExtracted 4 file(s) to ./extracted\n\n$ ls ./extracted\nindex.js  index.js.map  logo-47vhjydn.png  data-twdsv7gz.bin\n```\n\nThe first line reports the Bun version the binary was built with. It is\ninformational: if the version can't be read, the CLI warns and still extracts\n(see [A note on Bun 1.4.0](#a-note-on-bun-140)). The entrypoint is written as\n`index.js` unless `--no-normalize` is passed, and other bundled assets keep the\nhashed names Bun gave them. Any error is fatal and exits non-zero rather than\nwriting partial output.\n\n### Options\n\n| Flag                 | Description                                       |\n| -------------------- | ------------------------------------------------- |\n| `-o, --output <dir>` | Output directory (default: `./decompiled`)        |\n| `--no-normalize`     | Don't normalize entrypoint filename to `index.js` |\n| `-v, --version`      | Print version and exit                            |\n| `-h, --help`         | Print help and exit                               |\n\n### Examples\n\nExtract into a directory of your choosing:\n\n```sh\nbun-decompile ./my-app -o ./extracted\n```\n\nKeep the entrypoint's original bundled filename instead of renaming it to\n`index.js`:\n\n```sh\nbun-decompile ./my-app --no-normalize\n```\n\nInline sourcemaps, when present, are written alongside each file as `<file>.map`.\n\n## Library usage\n\n```ts\nimport { readFile } from \"node:fs/promises\";\n\nimport { extractBundledFiles, getExecutableVersion } from \"@andrewgross/bun-decompile\";\n\nconst binary = await readFile(\"./my-app\");\n\nconst { version, revision } = getExecutableVersion(binary);\nconst files = extractBundledFiles(binary);\n\nfor (const file of files) {\n  console.log(file.path, file.contents.byteLength);\n}\n```\n\nBoth entry points accept a `Buffer`, `Uint8Array`, `ArrayBuffer`, or `DataView`\n(`BinaryInput`). Views are read using their own `byteOffset`/`byteLength`, so a\npooled or sliced `Buffer` works correctly.\n\nThe library itself is runtime-agnostic — it touches no Node or Bun APIs and\noperates purely on `DataView`, so it runs unchanged in the browser.\n\n### API\n\n| Export                 | Description                                                        |\n| ---------------------- | ------------------------------------------------------------------ |\n| `extractBundledFiles`  | Returns `BundledFile[]` — `{ path, contents, sourcemap? }`         |\n| `getExecutableVersion` | Returns `{ version, revision }` read from the embedded Bun runtime |\n| `removeLeadingSlash`   | Path helper                                                        |\n\nStructural problems raise a subclass of `InvalidExecutableError`\n(`InvalidTrailerError`, `TotalByteCountMismatchError`, `VersionNotFoundError`)\nrather than returning partial or corrupt data.\n\n### A note on Bun 1.4.0\n\nBun 1.4.0 stopped embedding a literal version string after its ANSI\n`bun build v` marker — it became a runtime-substituted placeholder — which\nbreaks naive version detection. This fork falls back to scanning the runtime's\n`Bun v<version>` banner.\n\nVersion detection is informational only. `extractBundledFiles` is driven\nentirely by the binary's struct layout, so a future Bun release that changes the\nbanner again will still extract; the CLI degrades to a warning rather than\nfailing.\n\n## Development\n\n```sh\nbun install\n```\n\n| Script                   | Description                                   |\n| ------------------------ | --------------------------------------------- |\n| `bun run build`          | Compile to `dist/` (JS + type declarations)   |\n| `bun test`               | Unit tests                                    |\n| `bun run test:e2e`       | End-to-end tests against real Bun releases    |\n| `bun run typecheck`      | Typecheck without emitting                    |\n| `bun run lint`           | Prettier check                                |\n| `bun run build-fixtures` | Regenerate unit-test fixtures                 |\n| `bun run debug-binary`   | Inspect a binary's container, format, offsets |\n\n### Unit tests\n\nBuild the dummy test binary first, then run the suite:\n\n```sh\nbun build --compile --sourcemap=inline src/lib/tests/dummy/index.ts --outfile src/lib/tests/dummy/dummy\nDUMMY_VERSION=$(bun --version) bun test\n```\n\n### E2E tests\n\nCompiles a dummy binary with Bun v1.1.0, v1.1.26, v1.2.4, and v1.3.9 — one per\nmetadata format revision — and extracts each with the CLI. Then uses v1.3.14 to\ncross-compile `bun-linux-x64` and `bun-windows-x64` targets, exercising ELF and\nPE section extraction.\n\n```sh\nbun run test:e2e\n```\n\nDownloaded Bun versions are cached under `~/.cache/bun-decompile/`.\n\n## Credits\n\nOriginally created by [LuisAFK (@lafkpages)](https://github.com/lafkpages) as\n[bun-decompile](https://github.com/lafkpages/bun-decompile). The original\nproject worked out how Bun's standalone module graph is laid out and how to walk\nit — the foundation everything here is built on.\n\nThis fork adds:\n\n- Linux (ELF) and Windows (PE) `.bun` section support\n- V3 and V4 metadata formats (Bun 1.2.4+ and 1.3.0+)\n- Bun 1.4.0 version-banner detection, and non-fatal version detection\n- A refactor into a container-detection pipeline, plus a Node-compatible CLI\n\n## License\n\nCurrently **UNLICENSED** — no redistribution rights are granted. This is a\nderivative of [lafkpages/bun-decompile](https://github.com/lafkpages/bun-decompile),\nwhich publishes no license, so upstream's copyright is reserved by default and\nthis fork cannot grant terms over it. (\"UNLICENSED\" is npm's marker for _no\nlicense granted_ — it is not [The Unlicense](https://unlicense.org).)\n\nThis is waiting on a licensing decision from upstream; if it becomes possible,\nthis project would be released under the [MIT License](https://opensource.org/license/mit).\nUntil then, if you'd like to use it, open an issue.\n","readmeFilename":"README.md"}