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

Add deno cache --cached-only #28144

Open
sigmaSd opened this issue Feb 16, 2025 · 4 comments
Open

Add deno cache --cached-only #28144

sigmaSd opened this issue Feb 16, 2025 · 4 comments

Comments

@sigmaSd
Copy link
Contributor

sigmaSd commented Feb 16, 2025

I'm using deno in a flatpak app, and I needed this, currently the workaround I'm using is deno compile --cached-only but that's weird

@bartlomieju
Copy link
Member

This combination makes no sense - if you pass --cached-only then Deno can't fetch new modules from npm/jsr/remote servers, so if you already don't have everything cache the command will file. If you have everything cached already, then you don't need to run deno cache.

@sigmaSd
Copy link
Contributor Author

sigmaSd commented Feb 16, 2025

It makes sense if you populate npm cache manually , basically it works like this:

  • fetch the npm library and put under .cache/deno/npm
  • the deno cache --cached-only

why not just put the npm inside the project vendor folder directly:
-> because the node_modules structure with deno is complex there is .deno and there are symlinks, so it end up being easier to just populate the global cache

You can see what I'm doing here https://github.com/flathub/flathub/pull/6177/files

In reality its hacks on top of hacks, I'm not really sure if its a real use case, but currently its the only way I found to make deno + slint work inside flatpak, if deno compile worked for napi I wouldn't have needed this but its the current state of affair

@sigmaSd
Copy link
Contributor Author

sigmaSd commented Feb 17, 2025

I managed to make deno compile with slint inside the flatpak , you can checkout the latest version here https://github.com/flathub/flathub/pull/6177/files

It took working around #28129 and #23266

Also it would be great if deno becomes more flatpak friendly, the issue is in flatpak build system all dependencies needs to be declared you can't just download them, for node there is https://github.com/flatpak/flatpak-builder-tools/tree/master/node/flatpak_node_generator I can make something similar by parsing deno.lock, but the problem is where to put the fetched dependencies, I see that I have two choices

  1. put in under vendor and node_modules in the same project directory and ask the user to use vendor: true, the immediate problem here is that node_modules dir structre is complex it have .deno it have symlinks and it have .setup-cache.bin logic
  2. put it under DENO_DIR, and then run deno cache or deno compile, this seems to be the correct way, but the problem even though npm structure is clear, other dependencies structure is not clear from first glance, jsr and https imports seems to be saved as hash so I don't know how easy it is to replicate the correct structure

@sigmaSd
Copy link
Contributor Author

sigmaSd commented Feb 18, 2025

I was about going to close this because I found that there is deno install --cached-only, but it turns out deno install only looks at deno.json /package.json but not the remote modules specified directly inside files , which make it just a weaker version of deno cache

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

No branches or pull requests

2 participants