Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

deno install with import_map.json appears to be broken #15350

Open
andykais opened this issue Jul 30, 2022 · 4 comments
Open

deno install with import_map.json appears to be broken #15350

andykais opened this issue Jul 30, 2022 · 4 comments
Labels
needs investigation requires further investigation before determining if it is an issue or not

Comments

@andykais
Copy link

I have made this third party module https://deno.land/x/wallpal. It is a cli script, so I attempted to install it with

deno install -A --import-map=https://deno.land/x/wallpal@1.0.0/import_map.json https://deno.land/x/wallpal@1.0.0/wallpal.ts

deno prints this output, then exits with 1.

Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/encoding/_yaml/parse.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/encoding/_yaml/schema.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/encoding/_yaml/schema/mod.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/encoding/_yaml/stringify.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/encoding/_yaml/type.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/_util/assert.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/copy.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/empty_dir.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/ensure_dir.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/ensure_file.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/ensure_link.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/ensure_symlink.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/eol.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/exists.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/expand_glob.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/move.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/walk.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/io/buffer.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/io/readers.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/io/streams.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/io/util.ts
Download https://deno.land/x/wallpal@1.0.0/std@0.149.0/io/writers.ts
error: Module not found "https://deno.land/x/wallpal@1.0.0/std@0.149.0/fs/expand_glob.ts".
    at https://deno.land/std@0.149.0/fs/mod.ts:12:15

This project has an import map that looks like this:

{
  "imports": {
    "std/fs": "https://deno.land/std@0.149.0/fs/mod.ts",
    "std/io": "https://deno.land/std@0.149.0/io/mod.ts",
    "std/flags": "https://deno.land/std@0.149.0/flags/mod.ts",
    "std/encoding/": "https://deno.land/std@0.149.0/encoding/",
    "keypress/": "https://deno.land/x/keypress@0.0.8/",
    "/": "./",
    "./": "./"
  }
}

and imports that look like

import * as fs from 'std/fs'

It seems that deno is attempting to resolve these imports as if they are local to the wallpal module. These import maps work fine locally, but they fail with deno install, so I am inclined to believe there is a bug.

deno --version

deno 1.24.0 (release, x86_64-unknown-linux-gnu)
v8 10.4.132.20
typescript 4.7.4
@andykais andykais changed the title deno install with import_maps appears to be broken deno install with import_map.json appears to be broken Jul 30, 2022
@andykais
Copy link
Author

found a related issue that appears to have been closed
#10482
and the relevant pr that supposedly fixed this behavior
#10499

@kitsonk kitsonk added the needs investigation requires further investigation before determining if it is an issue or not label Aug 1, 2022
@andykais
Copy link
Author

andykais commented Aug 8, 2022

any update on this? I am wondering if I need to rework this pr to avoid using import maps, as currently there is no good way for users to install my package

@NfNitLoop
Copy link

NfNitLoop commented Mar 15, 2023

I'm running into this as well.

This being broken is sort of a big deal.

If you want to use a library that forces you to use import maps, you now give up being able to deno install your application. 😢


Update/Tangent: I'm also a bit worried seeing the Deno team using import maps for libraries. As the ecosystem grows, if this becomes a common pattern, every consumer of a library, all the way down the dependency chain, will have to start manually maintaining a larger and larger list of mapped imports, and manually investigating which versions work with which dependencies.

Maybe a better pattern would be to depend on a default version (so avoiding import maps) and have tooling that can (optionally) override that version with import maps as necessary?

@NfNitLoop
Copy link

@andykais A standard way of managing your dependencies is in a deps.ts file. See: https://deno.land/manual@v1.31.2/examples/manage_dependencies. That will let you deno install without needing to specify an import map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation requires further investigation before determining if it is an issue or not
Projects
None yet
Development

No branches or pull requests

3 participants