fix(cli, scanner): exclude source maps from pkg binaries#2383
Open
dividedmind wants to merge 2 commits into
Open
fix(cli, scanner): exclude source maps from pkg binaries#2383dividedmind wants to merge 2 commits into
dividedmind wants to merge 2 commits into
Conversation
Source maps (.js.map/.css.map) are only useful for browser devtools debugging of the bundled Vue/React viewer apps served from built/html; the CLI never reads them at runtime. They were also being pulled in wholesale from node_modules dependencies that ship dev sourcemaps in their published packages (e.g. lucide-vue ships ~13 MiB of maps across its cjs/umd/esm builds). Measured on Linux x64: excluding **/*.map via pkg's ignore config drops the uncompressed binary from 559.6 MiB to 410.0 MiB (-26.7%), verified with `--help` still working correctly.
dividedmind
force-pushed
the
claude/pkg-binary-size-investigation
branch
from
July 21, 2026 15:49
5873448 to
b4f258a
Compare
Same fix as the cli binary (previous commit): source maps are only useful for debugging in a browser/devtools, never read by the CLI at runtime, and get pulled in wholesale from node_modules dependencies that ship dev sourcemaps in their published builds. Scanner has no esbuild/HTML bundle step and doesn't set sourceMap in its own tsconfig, so this is entirely maps shipped inside its node_modules dependency tree. Smaller win than cli's (no large bundled UI to strip maps from) but free and zero-risk: Measured on Linux x64, uncompressed: 111.0 MiB -> 105.4 MiB (-5.1%). Verified `scan --help` still works on the rebuilt binary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Investigated why the packaged
appmapCLI binary is so large (~560 MiB uncompressed). Findings and a fix for the biggest, safest win, applied to bothpackages/cliandpackages/scanner.Investigation
Built
packages/clifornode22-linux-x64(uncompressed) and diffed a bare-Node-runtimepkgbinary against it to isolate the app payload (~74 MiB is just the Node runtime; the rest, ~485 MiB, is our payload). Then instrumentedpkg -dto get the full list of files it actually packs, and summed their on-disk sizes grouped by source package:built/html(bundled Vue/React viewer apps)node_modules/mermaid(see follow-up below)node_modules/js-tiktoken(tokenizer data)node_modules/lucide-vue(icon set)node_modules/elkjs(graph layout, mermaid dep)node_modules/better-sqlite3(native binary)The single biggest recurring pattern: development source maps (
.js.map/.css.map) were being packed everywhere — not just our ownbuilt/htmlesbuild output (~81 MiB of maps there alone, sinceesbuild's defaultsourcemap: trueinlines full original source per module), but also inside third-partynode_modulespackages that ship dev sourcemaps in their published builds (e.g.lucide-vueships ~13 MiB of maps across its cjs/umd/esm builds).Source maps are only consumed by a browser's devtools when a developer opens the panel for one of the bundled Vue/React viewer apps (
appmap.html,navie.html,sequenceDiagram.html, the query-ui). The CLI itself never reads them at runtime — confirmed no code underpackages/cli/srcreferences.mapfiles.Fix
@yao-pkg/pkgsupports a top-levelignoreconfig (glob patterns, matched with picomatch) that excludes matching files from everything it packs — both the explicitassetsglobs and anything pulled in via its own dependency walk. Added:This does not touch the esbuild config (
esbuild.html.tsstill generates maps inbuilt/, so local/npm-installed debugging workflows are unaffected) — it only strips maps from what actually goes into the packed executable. Applied the same one-line fix topackages/scanner.Results (Linux x64, uncompressed payload unless noted)
cli:
None)scanner (no esbuild/HTML bundle step, so this is entirely maps shipped inside its
node_modulesdependency tree — smaller win, still free):None)Verified
--help(cli) andscan --help(scanner) run correctly on the rebuilt binaries; no runtime code path in either package'ssrcreads.mapfiles.This is independent of and stacks with #2382 (Zstd → Brotli compression switch).
Follow-up not included in this PR
packages/naviepinsmermaid: "^9"while@appland/componentsuses^10.9.1, so yarn can't dedupe them — navie gets its own privatenode_modules/navie/node_modules/mermaid@9.4.3install just to callmermaid.parse()for AI-generated diagram syntax validation (packages/navie/src/lib/mermaid-filter.ts). That's ~20 MiB of pure duplication (measured after the source-map fix above; the raw duplicate was ~58 MiB before stripping maps).This was attempted and reverted: the runtime fix (bump to
^10.9.1,awaitmermaid's now-asyncparse(), unwrap Node'srequire(esm)default-export wrapping) works correctly under plain Node, but mermaid v10 is ESM-only and dynamically imports each diagram-type grammar atparse()call time — Jest's CJS module runner can't execute that, and fixing it brokepackages/cli's entire test suite (163/163 suites) via a shared global setup file that transitively loads navie. The right long-term fix is an ESM migration ofpackages/navie(or dual-building it likepackages/modelsalready does viatsup); revisit the mermaid dedup then.Test plan
appmap --help, the bundled HTML viewers (appmap open,appmap query ui), andappmap-scanner scan --helpstill work correctly on built binaries