You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(compile): prune managed npm snapshot to graph-reachable packages (#34741)
## Summary
`deno compile` used to embed the full managed npm resolution snapshot
(everything in the lockfile / package.json). Packages that were
resolved (e.g. via `deno.json` `imports` or `package.json`
`dependencies`) but never imported by the entrypoint were still
bundled into the executable, inflating its size considerably.
This PR adds an opt-in flag, `--exclude-unused-npm`, that reduces the
resolution snapshot to the closure of packages reachable from npm
specifiers in the module graph. Because non-statically-analyzable
dynamic imports won't appear in the graph, the optimization is
opt-in so the default behavior keeps the full snapshot and continues
to work for those cases (as discussed in #29338). Users with such
dynamic imports can still pass `--include npm:<pkg>` alongside the
flag to force inclusion.
The same pruning path is still taken implicitly under
`--unstable-npm-lazy-caching` (no change there).
## Test plan
- [x] New spec test `tests/specs/compile/compile_exclude_unused_npm`
mirrors the existing `unstable_npm_lazy_caching` test but uses
the new flag, confirming the unused `@denotest/subtract` package
is no longer embedded.
- [x] Existing `unstable_npm_lazy_caching` and
`npm_pkgs_lockfile_unused` tests continue to express the
intended behavior unchanged.
Closes#21504Closesdenoland/divybot#437
---------
Co-authored-by: divybot <divybot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Divy Srivastava <me@littledivy.com>
0 commit comments