Skip to content

fix: error on specifiers that fail to resolve - #500

Merged
dsherret merged 1 commit into
denoland:mainfrom
dsherret:fix_unresolved_specifiers
Jul 26, 2026
Merged

fix: error on specifiers that fail to resolve#500
dsherret merged 1 commit into
denoland:mainfrom
dsherret:fix_unresolved_specifiers

Conversation

@dsherret

Copy link
Copy Markdown
Collaborator

deno_graph's module_errors() explicitly does not include resolution errors, so a specifier that failed to resolve was silently emitted into the output as-is, which is broken for anything that isn't an npm dependency:

// input
import * as path from "@std/path";
import { globToRegExp } from "@std/path/glob-to-regexp";

// output
import * as path from "./deps/jsr.io/@std/path/1.1.6/mod.js";
import { globToRegExp } from "@std/path/glob-to-regexp"; // <-- broken

Now the graph is also walked for resolution errors, which surfaces the same message Deno gives:

error: Import "@std/path/glob-to-regexp" not a dependency and not in import map from "file:///.../util.ts"
    at file:///.../util.ts:2:30

The walk uses GraphKind::All and follow_dynamic: true rather than the narrower semantics of graph.valid(), because dnt emits type-only and dynamic imports too, so an unresolved specifier in either position is broken in the output in exactly the same way.

In the case from the issue the specifier failed to resolve because the deno.json was passed as importMap rather than configFile. Like deno --import-map, that is read as a plain import map, so bare specifier mappings are not expanded to cover sub paths (deno run --import-map=deno.json fails on the same import). Documented that on the option.

Closes #475

deno_graph's module errors do not include resolution errors, so a
specifier that failed to resolve was silently emitted into the output
as-is. Walk the graph for those errors as well.

Closes denoland#475
@dsherret
dsherret merged commit 245c653 into denoland:main Jul 26, 2026
5 checks passed
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.

Mappings only work for default entry points of JSR packages?

1 participant