Repository navigation
perf(packaging): prune JS source maps from all packaged node_modules - #17638
Conversation
Generalizes the @linear/sdk-scoped prune to every packaged dependency, matching the existing type-declaration prune's single-predicate walk over Resources/node_modules. Recovers ~1.01 MB beyond the SDK. Nothing in the packaged app enables Node source-map support (no --enable-source-maps, no setSourceMapsEnabled, no source-map-support require), and the CLI launchers strip NODE_OPTIONS, so these maps were never read. Orca's own main-process maps live outside node_modules and already ship as a separate release artifact.
Greptile SummaryThe PR generalizes packaged dependency source-map pruning from
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| config/packaged-runtime-node-modules.cjs | Broadens packaged JavaScript source-map removal to all runtime dependencies while retaining the existing traversal and file-matching behavior. |
| config/scripts/packaged-linear-sdk-prune.test.mjs | Removes the superseded SDK-specific source-map pruning tests. |
| config/scripts/packaged-source-map-prune.test.mjs | Adds generalized regression coverage for whole-tree source-map pruning and preservation of unrelated map artifacts. |
Reviews (2): Last reviewed commit: "Merge branch 'main' into nwparker/prune-..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe runtime cleanup now removes Merge Risk: ⚪ Minimal · up to This change removes JavaScript source maps from packaged dependencies while preserving runtime code and unrelated map files. No actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description provides detailed coverage of the change, rationale, measured impact, safety analysis, and tests. It does not include the required linked issue, explicit Visual Proof section with N/A, or the template checklist and section headings.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Generalizes the @linear/sdk-scoped source-map prune into a single rule over the whole packaged Resources/node_modules, renaming prunePackagedLinearSdkSourceMaps → prunePackagedRuntimeSourceMaps and LINEAR_SDK_SOURCE_MAP_RE → JS_SOURCE_MAP_ARTIFACT_RE, and porting the test suite to the broader scope.
prunePackagedRuntimeSourceMaps— walks all ofResources/node_moduleswith the samepruneMatchingFileshelper the type-declaration prune uses, keyed onJS_SOURCE_MAP_ARTIFACT_RE(\.(?:c|m)?js\.map$).- Renamed export and call site —
prunePackagedRuntimeNodeModulesnow invokes the generalized prune; the old symbol has no remaining references anywhere in the repo. - Test port —
packaged-linear-sdk-prune.test.mjs→packaged-source-map-prune.test.mjs, extending coverage tojs-yaml/node-pty/electron-updatermaps, disjoint-predicate preservation (.d.ts.mapsurvives), and the filename-basedmetadata.json.mapexception.
I independently re-verified the load-bearing safety claims: no source-map-support / --enable-source-maps / setSourceMapsEnabled usage in source (only build-time pnpm-lock entries), '!out/**/*.map' keeps Orca's own maps out of node_modules, and the new test file passes (4 tests).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…tablyai#17638) Generalizes the @linear/sdk-scoped prune to every packaged dependency, matching the existing type-declaration prune's single-predicate walk over Resources/node_modules. Recovers ~1.01 MB beyond the SDK. Nothing in the packaged app enables Node source-map support (no --enable-source-maps, no setSourceMapsEnabled, no source-map-support require), and the CLI launchers strip NODE_OPTIONS, so these maps were never read. Orca's own main-process maps live outside node_modules and already ship as a separate release artifact.

Generalizes the
@linear/sdk-scoped source-map prune from #17530 into asingle rule over the whole packaged
Resources/node_modules, mirroring theneighboring
prunePackagedRuntimeTypeDeclarations.prunePackagedLinearSdkSourceMaps->prunePackagedRuntimeSourceMaps,LINEAR_SDK_SOURCE_MAP_RE->JS_SOURCE_MAP_ARTIFACT_RE(the pattern wasalready generic).
Measured win
Read-only measurement over the exact package set
createPackagedRuntimeNodeModuleResources('darwin')copies:@linear/sdk(already pruned by #17530)js-yamlelectron-updaterbuilder-util-runtimenode-ptylazy-valget-caller-fileNewly recovered: 1033.4 KB (~1.01 MB) across 5 additional packages.
Total under the rule: 7.53 MB.
Safety audit
1. Does anything enable Node source-map support in the packaged app? No.
Repo-wide grep (excluding
node_modules) for--enable-source-maps,setSourceMapsEnabled,source-map-support,sourceMapSupportreturnszero source hits - only
pnpm-lock.yamlentries, where[email protected]is a build-time dependency ofapp-builder-lib,not a runtime one. Electron does not enable source-map support by default,
and no
NODE_OPTIONSvalue anywhere sets it (every occurrence is--max-old-space-sizefor CI builds, or the build scripts'appendBuildOldSpaceOption). The shipped CLI launchers(
resources/darwin/bin/orca,resources/linux/bin/orca-ide,src/main/cli/cli-dev-launcher.ts) activelyunset NODE_OPTIONSintoORCA_NODE_OPTIONS, so even a user withNODE_OPTIONS=--enable-source-mapsin their environment does not turn it on.
src/relay/ai-vault-service-spawnlikewise drops
NODE_OPTIONSfor its sidecar. These files were never read.2. Do the affected packages require
source-map-supportthemselves? No.grep -r source-map-supportoverelectron-updater/out,builder-util-runtime/out,js-yaml,node-pty/libreturns nothing, andnone of them declare it in
dependencies. (For the record, even if one did,source-map-supportswallows a missing.mapand falls back to theunmapped frame.)
3. Is any
.js.maploaded as data or as a module? No. Norequire(...'.js.map')and no.mappath read in packaged code. Everyin-repo
.js.mapstring is a test fixture, a comment, or theout/**/*.map-related build config. The prune is filename-based, so thetest suite pins that a non-JS
metadata.json.mapsurvives.4. Scope safety - can it ever touch the developer's checkout? No.
config/electron-builder.config.cjsafterPackderivesresourcesDirpurely from
context.appOutDir(<appOutDir>/<Product>.app/Contents/Resourceson darwin,
<appOutDir>/resourceselsewhere) and throws if it does notexist.
appOutDiris electron-builder's packaged output directory; the reporoot is never on that path, so the walk starts inside
dist/and cannotreach the checkout's
node_modules. The prune additionally no-ops if<resourcesDir>/node_modulesis absent.pruneMatchingFilescannot escapethe tree either: it uses
readdirSync(dir, { withFileTypes: true })andrecurses only on
entry.isDirectory(), deleting only onentry.isFile()-a
Direntfor a symlink reportsisSymbolicLink()and false for both, sosymlinks are neither followed nor deleted. This is the same walk the
existing type-declaration prune has been using.
5. Collision with the type-declaration prune? None - the predicates are
disjoint.
TYPE_DECLARATION_ARTIFACT_RE = /\.d\.(?:c|m)?ts(?:\.map)?$/matches
.d.ts.map/.d.cts.map/.d.mts.map;JS_SOURCE_MAP_ARTIFACT_RE = /\.(?:c|m)?js\.map$/matches.js.map/.cjs.map/.mjs.map. No filename can satisfy both. A regression testasserts that
prunePackagedRuntimeSourceMapsleavesmain.d.ts.mapalone.6. Debugging impact: negligible. This does remove mapped stack frames for
dependency code in a packaged build - but given #1, Node was never
consuming those maps anyway, so nothing that works today stops working.
Orca's own main-process maps are unaffected:
filesalready contains'!out/**/*.map', and release-cut bundlesout/main/**/*.js.mapinto theorca-sourcemaps-<tag>.ziprelease artifact, which lives outsidenode_modulesand outsideresourcesDir.Tests
config/scripts/packaged-linear-sdk-prune.test.mjs->packaged-source-map-prune.test.mjs(the file is no longer SDK-specific).Coverage: the SDK case still passes and the pruned SDK still
require()s;js-yaml/node-pty/electron-updatermaps are now pruned too;.d.ts.mapsurvives the source-map prune;metadata.json.mapsurvives boththe direct call and the aggregate
prunePackagedRuntimeNodeModules.Verified with
pnpm test config/scripts/packaged-source-map-prune.test.mjs config/scripts/electron-builder-config.test.mjs(41 passed),pnpm exec oxlint, andpnpm tc. No full package build was run.