-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat: Deno.cacheDir, Deno.cache, resolveCacheModulePath #6891
Comments
This was removed in #6385. We can maybe bring some of these back without the
Duplicate of #4752.
Duplicate of #2096 (tracking issue for programmatic |
I wonder what your exact use case is? I'm researching vscode extensions now and the thought is that we might want to expose language service from Deno. If this is what you're after maybe this feature isn't needed. |
My specific use case is a tool that works natively with Deno and has no npm deps. The goal is to make Deno modules work in a browser without the need of bundling them. The features proposed in this issue are implementable in Btw: The same use case is for this issue about import maps. |
Update: Bundler is the proof of concept project. I had to implement the functionality of |
I'm not a big fan of making |
Interesting, I would have thought exactly the opposite. I like the idea of denos caching system. That is why I think it should give access via API. Deno can change when needed and also adjust the API instead of having 3rd party modules that will break when changes happen. In that sense the functionality boils down to two features:
What would you think of that? |
Reading from deps cache is useful for Deno build tools. It allows https://deno.land/x/deno2node to work without Cache access can be exposed without leaking implementation details. This is what https://deno.land/x/fromdeno_cache does: /**
* @permissions `--allow-read --allow-env`
* @returns cached `Response` on success.
* @throws `Deno.errors.NotFound` when the URL isn't cached.
*/
export declare function readCache(url: string | URL): Promise<Response>;
/**
* If `Response` isn't cached, performs the request and caches `Response`.
* @permissions `--allow-net --allow-write --allow-read --allow-env`
*/
export declare function fetchCache(url: string | URL): Promise<Response>; I think these two belong in core, where they can reuse Deno's caching logic. After fetch cache is implemented (#3756) and used for remote caching dependencies, |
Closing because of reasons given in #11829 |
Proposal
I propose these implementations:
Deno.cacheDir()
Implementation of rust's cache_dir
Deno.cache(path: string, options: CacheOptions)
access to
deno cache
as a methodresolveCacheModulePath(path: string)
Native way to resolve an url to the local cache file. Either returns the
filepath
if the file is cached ornull
if not.Example:
Maybe Deno needs a dedicated
std/cache
module for functions likeresolveCachedModulePath
and other cache related stuff?Use case
The Deno cache system is great. For dev tools written for Deno it is important to have access to the local files for a certain path when bundling or compiling, else it needs to be either re-downloaded or cached with a custom cache system.
What are your thoughts on this?
References:
#4069
https://denolib.gitbook.io/guide/advanced/deno_dir-code-fetch-and-cache
https://doc.deno.land/https/github.com/denoland/deno/releases/latest/download/lib.deno.d.ts
https://deno.land/manual/runtime/compiler_apis
https://deno.land/x/cache
The text was updated successfully, but these errors were encountered: