Skip to content

feat(cli): add deno list subcommand to list declared dependencies#34972

Merged
bartlomieju merged 8 commits into
mainfrom
feat/deno-list
Jun 22, 2026
Merged

feat(cli): add deno list subcommand to list declared dependencies#34972
bartlomieju merged 8 commits into
mainfrom
feat/deno-list

Conversation

@bartlomieju

@bartlomieju bartlomieju commented Jun 6, 2026

Copy link
Copy Markdown
Member

Deno has no equivalent of npm ls / pnpm list for inspecting a
project's declared dependencies. deno info is close but answers a
different question: it walks the module graph from an entrypoint and
reports every module reached, at file granularity. There is no way to
ask "what packages does this project depend on?" straight from the
manifest, without an entrypoint, grouped by package and version.

This adds a deno list subcommand that reads the dependencies declared
in deno.json imports and package.json
dependencies/devDependencies, resolves their current versions, and
prints them. By default it shows a flat table of direct dependencies;
--depth N renders the resolved dependency tree N levels deep (for
both npm and jsr, sourced from the lockfile). --prod and --dev
filter by dependency kind, positional name filters support wildcards
and ! negation (reusing the same matcher as deno outdated), and
--recursive includes all workspace members.

The dependency enumeration and version resolution reuse the existing
DepManager that backs deno outdated, so this is mostly a new
presentation layer plus flag wiring.

Closes #26517

@bartlomieju bartlomieju added this to the 2.9.0 milestone Jun 7, 2026
Comment thread cli/args/flags.rs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DENO_HELP is not updated with list subcommand in "Dependency management" section

Comment thread cli/tools/pm/list.rs Outdated
- Add the list subcommand to the Dependency management section of the
  top-level help output.
- Remove the --json flag and its (newly invented) output format. Rather
  than ship a Deno-specific JSON shape, JSON output can be reintroduced
  later in an existing, tool-consumable format. Rework the prod/dev/
  filter spec tests to assert against the table output instead.
- Add a jsr dependency (@denotest/add) to the list spec fixture and a
  dedicated 'jsr' test, covering the previously untested DepKind::Jsr
  flat and tree paths. Update flat/prod/depth expectations since jsr
  roots sort before npm.
- Comment the npm_by_base first-wins behavior for packages present with
  distinct peer sets, and note the ASCII byte-width assumption in the
  flat table.
The jsr -> npm edges in the dependency tree were built directly from the
lockfile `specifiers` value (`name@<resolved>`). When the npm dependency
carries a peer suffix, that value can be formatted differently from the
`content.npm` key (e.g. `[email protected]` vs `name@version_peer@1`),
so the child id didn't match any npm node and the whole subtree was
dropped from `deno list --depth N`.

Prefer an exact match on the npm key (pins the precise peer variant) and
fall back to mapping the base `name@version` onto its node via the same
`npm_by_base` table that root resolution uses.
@bartlomieju
bartlomieju merged commit 755552e into main Jun 22, 2026
267 of 270 checks passed
@bartlomieju
bartlomieju deleted the feat/deno-list branch June 22, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deno list / deno info --all

1 participant