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 gfm vendoring issues #21415

Open
mcandeia opened this issue Dec 1, 2023 · 11 comments
Open

Deno gfm vendoring issues #21415

mcandeia opened this issue Dec 1, 2023 · 11 comments
Labels
bug Something isn't working correctly design limitation something that can't be fixed or is too hard to fix vendor related to the vendor subcommand

Comments

@mcandeia
Copy link

mcandeia commented Dec 1, 2023

Version: Deno 1.38.4

I encountered a bug related to vendoring dependencies while using deno. The problem becomes apparent when attempting to vendor the deno-gfm library. For detailed information on how to reproduce this issue, please refer to the repository:

https://github.com/mcandeia/deno-vendor-bug

To reproduce, fork the repository and try to run with --no-remote options poiting to vendor/import_map.json file

@dsherret
Copy link
Member

dsherret commented Dec 1, 2023

Does it work with the new vendor feature (should be much more reliable)? You might want to use that instead https://deno.com/blog/v1.37#vendor-as-cache-override-unstable (though it doesn't work on deploy atm)

Note that the deno vendor subcommand may go away in the future and be moved to a separate library: #20584

@dsherret dsherret added bug Something isn't working correctly vendor related to the vendor subcommand labels Dec 1, 2023
@mcandeia
Copy link
Author

mcandeia commented Dec 3, 2023

@dsherret I couldn't make it work either, it's not clear to me if I should run deno cache --vendor main.tsx and then I can run with --no-remote ? previously It was possible by using the generated import_map inside vendor folder, but looks like it was removed, right?

@mcandeia
Copy link
Author

mcandeia commented Dec 3, 2023

I tried with --vendor using deno run --vendor main.tsx and it seemed to work, but with a large project I have to remove node_modules/.deno to work, probably something that changes based on the SO/VM.

Also: I noticed that the node_modules still being downloaded even with --vendor, is that correct?
image

image

@mcandeia
Copy link
Author

ping @dsherret

@dsherret dsherret added the design limitation something that can't be fixed or is too hard to fix label Dec 18, 2023
@dsherret
Copy link
Member

I couldn't make it work either, it's not clear to me if I should run deno cache --vendor main.tsx and then I can run with --no-remote?

Basically once "vendor": true is in the config file, then you can run deno cache main.tsx and then from then use deno run with --no-remote. If not setting in the config file, then you need to provide --vendor to each command.

Also: I noticed that the node_modules still being downloaded even with --vendor, is that correct?

They should be vendored on first run.

but with a large project I have to remove node_modules/.deno to work, probably something that changes based on the SO/VM.

You can disable the node_modules auto-install/vendoring by setting "nodeModulesDir": false.


So I looked into this issue more and I think this is a design limitation with import maps. I'm not super knowledgable on them, but it seems like there's no way to map a specifier like https://esm.sh/marked@5.1.0/ to something like ./esm.sh/marked@5.1.0.js. When I try I get Invalid target address "file:///V:/deno-vendor-bug/vendor/esm.sh/marked@5.1.0.js" for package specifier "https://esm.sh/marked@5.1.0/". Package address targets must end with "/".

I opened a PR denoland/deno-gfm#83 -- that should fix this and not require code changes.

@dsherret
Copy link
Member

Upgrading to deno-gfm 0.3.0 should fix the issue now.

@mcandeia
Copy link
Author

Thanks, will check @dsherret

@mcandeia
Copy link
Author

Now it's a different problem,
Tested with: https://github.com/deco-sites/start

(using Deno 1.39.1)
deno cache --vendor dev.ts will generate a vendor folder with no import_map generated. I don't know if I did something wrong, but couldn't make it work @dsherret

image

@dsherret
Copy link
Member

Yeah, that's expected. The --vendor feature (recommended use as { "vendor": true } in deno.json) is a completely different more reliable way of doing vendoring that does a cache override and doesn't use an import map (https://deno.com/blog/v1.37#vendor-as-cache-override-unstable). I wouldn't recommend using it yet though because it's not supported on Deploy yet.

Regarding the original deno vendor issue, it seems there's a new issue that's surfaced:

> deno vendor main.tsx
error: Failed resolving types. Relative import path "Instance" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/marked@9.1.1/lib/marked.d.ts"
    at https://esm.sh/v135/marked@9.1.1/lib/marked.d.ts:553:39

@mcandeia
Copy link
Author

mcandeia commented Dec 22, 2023

Yeah, that's expected. The --vendor feature (recommended use as { "vendor": true } in deno.json) is a completely different more reliable way of doing vendoring that does a cache override and doesn't use an import map

Oh, I forgot to mention that the problem is exactly that, it changed my deno.json file and points to an import_map.json that do not exists @dsherret, it's easy to reproduce, just try with the repo that I mentioned

@mcandeia
Copy link
Author

mcandeia commented Dec 22, 2023

Just to let you know. I changed my approach because I couldn't make it work with vendor command nor --vendor option. It was much simpler to just zip the entire DENO_DIR and share it between machines. It seems to be a poor-man's solution, but I think vendoring is not a deno priority right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly design limitation something that can't be fixed or is too hard to fix vendor related to the vendor subcommand
Projects
None yet
Development

No branches or pull requests

2 participants