deno/tests/specs/run/import_map_bare_specifier
Nathan Whitaker c36a20f6bb
feat(run): resolve main module with workspace resolver (#29928)
Closes https://github.com/denoland/deno/issues/29897.
Closes https://github.com/denoland/deno/issues/14066.
Closes https://github.com/denoland/deno/issues/19955.

With this PR we'll attempt to resolve bare specifiers passed to `run` or
`serve` with the workspace resolver. This means you can run specifiers
that are defined in your import map/package.json.

If the specifier looks like a path (starts with `.`, or is an absolute
path) then we won't try to resolve it via the import map.

This does have the potential to break someone, in the case that you have
something like

```
{
  "imports": { "foo.ts": "./bar.ts" }
}
```

and you have a file named `foo.ts`, previously `deno run foo.ts` would
run `./foo.ts`, now we would run `./bar.ts`. I can't see a way around
that without doing an extra stat to see if the file exists, or deferring
this to module load time (which seems complex). I don't think many
people would hit that, and if someone does there's a simple fix – just
add `./` to the front.

From my benchmarking, this change has no effect on startup time
2025-06-27 19:14:30 -07:00
..
src feat(run): resolve main module with workspace resolver (#29928) 2025-06-27 19:14:30 -07:00
__test__.jsonc feat(run): resolve main module with workspace resolver (#29928) 2025-06-27 19:14:30 -07:00
absolute_unix.out feat(run): resolve main module with workspace resolver (#29928) 2025-06-27 19:14:30 -07:00
absolute_windows.out feat(run): resolve main module with workspace resolver (#29928) 2025-06-27 19:14:30 -07:00
deno.jsonc feat(run): resolve main module with workspace resolver (#29928) 2025-06-27 19:14:30 -07:00
direct_file.out feat(run): resolve main module with workspace resolver (#29928) 2025-06-27 19:14:30 -07:00
jsr_specifier.out feat(run): resolve main module with workspace resolver (#29928) 2025-06-27 19:14:30 -07:00
local_file.out feat(run): resolve main module with workspace resolver (#29928) 2025-06-27 19:14:30 -07:00
npm.out feat(run): resolve main module with workspace resolver (#29928) 2025-06-27 19:14:30 -07:00
relative_mapping.out feat(run): resolve main module with workspace resolver (#29928) 2025-06-27 19:14:30 -07:00