Skip to content

fix(npm): support catalog: protocol in deno.json imports#35168

Merged
bartlomieju merged 1 commit into
mainfrom
fix/catalog-deno-json-imports
Jun 13, 2026
Merged

fix(npm): support catalog: protocol in deno.json imports#35168
bartlomieju merged 1 commit into
mainfrom
fix/catalog-deno-json-imports

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Previously catalog: was only supported in package.json dependencies. Using it in deno.json imports was silently broken everywhere: deno run failed with Unsupported scheme "catalog" for module "catalog:", and deno install skipped the entry entirely, so the package was never materialized into node_modules (and its CLI bin entries were never created).

This PR makes catalog: / catalog:<name> work in deno.json imports (and scopes):

  • Import map expansion (libs/resolver/workspace.rs): when building the synthetic import map, catalog: values are replaced with the npm:<name>@<version_req> specifier from the workspace root catalog (package name taken from the import key, matching pnpm semantics). A trailing-slash entry is added so subpath imports work, mirroring the existing npm: expansion. A missing catalog entry fails with the same error already used for package.json catalog deps: Package '<name>' not found in catalog. External import map files are not expanded, consistent with how the bare specifier expansion only applies to inline imports.
  • Install dep collection (libs/npm_installer/package_json.rs): NpmInstallDepsProvider resolves catalog: values in deno.json imports so deno install materializes the package (and its bin entries) into node_modules in auto and manual modes.
  • Lockfile workspace deps (libs/config, libs/resolver/lockfile.rs): ConfigFile::dependencies() now takes the workspace catalogs and resolves catalog: import entries, so the resolved req is tracked under the lockfile's workspace config (previously the entry was dropped). Linked packages pass empty catalogs since another workspace's catalog shouldn't apply to them.

Verified that deno run, deno install (none/auto/manual), subpath imports, workspace members referencing the root catalog, named catalogs, and deno compile all work, with behavior matching plain npm: import map entries.

Spec tests added for install materialization in manual mode (including a named catalog), running without a node_modules dir, and the missing-catalog-entry error.

Fixes #35165

Expand `catalog:`/`catalog:<name>` values in deno.json "imports"
and "scopes" to the "npm:<name>@<version_req>" specifier from the
workspace root catalog when building the synthetic import map, so
resolution, deno install (including materializing the package and its
bin entries into node_modules), the lockfile, and deno compile all see
a regular npm specifier.

Fixes #35165
@bartlomieju
bartlomieju merged commit 8297980 into main Jun 13, 2026
136 checks passed
@bartlomieju
bartlomieju deleted the fix/catalog-deno-json-imports branch June 13, 2026 07:22
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.

catalog protocol imports are not materialized into node_modules with nodeModulesDir: "manual"

1 participant