Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support deno run resolving bare specifiers with import map #19955

Open
leighmcculloch opened this issue Jul 26, 2023 · 3 comments
Open

Support deno run resolving bare specifiers with import map #19955

leighmcculloch opened this issue Jul 26, 2023 · 3 comments
Labels
suggestion suggestions for new features (yet to be agreed)

Comments

@leighmcculloch
Copy link
Contributor

Proposal

Support deno run resolving bare specifiers with the import map.

For example:

If the deno.json file contains an import map that maps lume/ to https://deno.land/x/lume@v1.18.1/:

{
  "imports": {
    "lume/": "https://deno.land/x/lume@v1.18.1/"
  }
}

It be possible to reference the bare specifier with deno run:

deno run lume/cli.ts

Instead of:

deno run https://deno.land/x/lume@v1.18.1/cli.ts

Why

Today bare specifiers are interpreted inconsistently by deno run and an import. imports with bare specifiers interpret them using an import map and relative paths must be prefixed with ./. deno run however treats a bare specifier as a relative path.

This prevents developers from conveniently referencing versions in an import map in deno run commands, or in deno tasks. It is easy to accidentally use the wrong version when running a tool with deno run when the project is configured for a different version.

It is possible to work around this by piping an import to the deno run command, but this is not intuitive. For example:

echo "import 'lume/cli.ts'" | deno run -
@dsherret dsherret added the suggestion suggestions for new features (yet to be agreed) label Jul 26, 2023
@dsherret
Copy link
Member

This was just implemented for deno info. I think it makes sense to do for all sub commands.

#19781

@bartlomieju
Copy link
Member

PRs are welcome. Would be great to ship it in v1.36 next week.

@oscarotero
Copy link
Contributor

This would be awesome. I've requested something similar in #14066 without luck :)

@dsherret dsherret changed the title Support deno run resolving bare specifiers with import map Support deno run resolving bare specifiers with import map and package.json Oct 7, 2024
@dsherret dsherret changed the title Support deno run resolving bare specifiers with import map and package.json Support deno run resolving bare specifiers with import map Oct 7, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants