Skip to content

fix(config): surface invalid "exports" map in linked/workspace packages#34473

Merged
bartlomieju merged 2 commits into
mainfrom
orch/divybot-272
May 29, 2026
Merged

fix(config): surface invalid "exports" map in linked/workspace packages#34473
bartlomieju merged 2 commits into
mainfrom
orch/divybot-272

Conversation

@divybot

@divybot divybot commented May 28, 2026

Copy link
Copy Markdown
Contributor

When you use links (formerly patch) to point a JSR dependency at a local
package, and that local package's deno.json has an invalid exports map
(e.g. a key like "types" instead of "./types"), Deno would silently ignore
the linked package and fall back to fetching it from the JSR registry. The user
was then greeted with a confusing error:

error: JSR package not found: @deno/i-dont-exist-yet

…with no hint that the real problem was a typo in the exports map — not even
in the internal logs.

Cause

Workspace::resolver_jsr_pkgs() builds the list of resolvable workspace/linked
JSR packages and parses each package's exports map with
config_file.to_exports_config().ok()?. The .ok()? silently converts a parse
error into None, dropping the entire package from the list. With the package
gone, the bare specifier no longer resolves locally and resolution falls back to
the registry.

Fix

Add a new WorkspaceDiagnosticKind::InvalidExports diagnostic and validate the
exports map of every config file — both workspace members and links — in
Workspace::diagnostics(). The error message produced by to_exports_config()
is already clear and actionable, so the user now sees, for example:

Warning Invalid "exports" field in configuration file. The 'types' export must start with './'. Did you mean './types'?
    at file:///.../foo/deno.json

instead of silence. This is consistent with how Deno already surfaces other
config problems (MissingExports, InvalidMemberName, etc.) as workspace
diagnostics.

Tests

  • Unit test test_link_invalid_exports in deno_config verifying the
    diagnostic is emitted for a linked package with an invalid exports map.
  • Spec test tests/specs/jsr/link_invalid_exports covering both a valid
    exports map (resolves locally, no warning, no registry fetch) and an invalid
    one (warning surfaced).

Fixes #25435.

Closes denoland/orchid#272

When a linked (or workspace member) JSR package had an invalid "exports"
map (e.g. a key like "types" instead of "./types"), the package was
silently dropped during resolution via `resolver_jsr_pkgs` (`.ok()?`),
causing Deno to fall back to fetching it from the JSR registry. This
produced a confusing "JSR package not found" error with no indication of
the real problem — not even in the internal logs.

Add an `InvalidExports` workspace diagnostic that validates the "exports"
map for every config file (members and links) and reports exactly what is
wrong, so the user gets an actionable warning instead of silence.

Closes denoland/orchid#272

Co-Authored-By: Divy Srivastava <[email protected]>
@divybot divybot changed the title [denoland/deno#25435] Bug: patch feature silently fails on invalid exports map fix(config): surface invalid "exports" map in linked/workspace packages May 29, 2026
@divybot

divybot commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

CI note: the only failing check is `test node_compat (3/3) debug` on linux-aarch64 / macos-aarch64 / macos-x86_64, which fails on `node_compat::internet::test-dns-any.js` — a live-DNS `ANY` query test in the `internet::` category. The same shard passes on linux-x86_64 and the Windows runners, so this is a network flake unrelated to this change (which only adds a workspace config diagnostic and cannot affect that test — node_compat runs with `--quiet`, which suppresses the new warning anyway). A re-run of the failed shard should clear it.

@bartlomieju bartlomieju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clean, focused fix. The new InvalidExports diagnostic is symmetric with the existing MissingExports check and runs for both workspace members and links. Unit test directly verifies the diagnostic; spec test confirms user-visible behavior.

One observation (non-blocking): resolver_jsr_pkgs at libs/config/workspace/mod.rs:953 still drops the package via .ok()?, so resolution still falls back to the registry — the warning is what tells the user why. That seems like the right scope for this PR.

The flaky node_compat::internet::test-dns-any.js shard is unrelated.

@bartlomieju
bartlomieju merged commit fb1b499 into main May 29, 2026
136 checks passed
@bartlomieju
bartlomieju deleted the orch/divybot-272 branch May 29, 2026 07:03
littledivy added a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
…es (denoland#34473)

When you use `links` (formerly `patch`) to point a JSR dependency at a
local package, and that local package's `deno.json` has an **invalid `exports`
map** (e.g. a key like `"types"` instead of `"./types"`), Deno would silently
ignore the linked package and fall back to fetching it from the JSR registry.
The user was then greeted with a confusing error:

```
error: JSR package not found: @deno/i-dont-exist-yet
```

…with no hint that the real problem was a typo in the `exports` map —
not even in the internal logs.

## Cause

`Workspace::resolver_jsr_pkgs()` builds the list of resolvable
workspace/linked JSR packages and parses each package's `exports` map with
`config_file.to_exports_config().ok()?`. The `.ok()?` silently converts
a parse error into `None`, dropping the entire package from the list. With the
package gone, the bare specifier no longer resolves locally and resolution falls
back to the registry.

Fixes denoland#25435.

Co-authored-by: divybot <[email protected]>
Co-authored-by: Divy Srivastava <[email protected]>
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.

Bug: patch feature silently fails on invalid exports map

3 participants