Skip to content

Caching and loading non-importable resources #5987

@KSXGitHub

Description

@KSXGitHub

Problem

I often find myself needing to load non-JavaScript non-TypeScript assets, and various problems arise:

  • Local module (in git repo) has to use fs but remote module has to use fetch.
  • The assets cannot be cached.
  • The assets cannot be bundled.

Suggestion

Add some way to annotate assets using comments, and fetch should support those assets. For example:

// @deno-asset './assets/foo.wasm'
// @deno-asset './assets/bar.png'
await fetch(new URL('./assets/foo.wasm', import.meta.url))
await fetch(new URL('./assets/bar.png', import.meta.url))
// --allow-net is not required since it reads from cache

Alternatives

There is asset reference proposal that is likely not going to get to stage 3 anytime soon.

import assertion proposal had reached stage 3.

Import types text and bytes are being discussed in whatwg/html#9444

Metadata

Metadata

Assignees

No one assigned

    Labels

    clirelated to cli/ dirsuggestionsuggestions for new features (yet to be agreed)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy