#124Implement `@fetch`

  • avatar~jeff-hykincommented · 2 years ago
    Author

    (Following my cursed adventures trying to bundle wasm, pngs, exes, and more inside a deno executable)

    Idk where in the roadmap this belongs, but I think there should eventually be some comptime embed tool. (Even the C lang added preprocessor support for #embed apparently)

    Maybe something like @embedUint8Array, @embedUtf8, @embedAscii

    let myImage = @embedUint8Array("./img.PNG")
    let myConfig = @embedUtf8("config.toml")
    

    Milestone: 0.3.0.

  • avatar~jeff-hykin changed the status to Todo · 2 years ago
  • avatar~lino-levancommented · 2 years ago

    both me and dave are for this. Likely it'll just be @embed which embeds are byte array and you could always comptime it to whatever you want

  • avatar~clovercommented · 2 years ago
    Owner

    it is going to be named @fetch and it will be a comptime-knonw blob object. this will support urls just like @import does

  • avatar~jeff-hykincommented · 2 years ago
    Author

    named @fetch

    While I would be a fan of the simplicity. I feel like the caching behavior could be weird/unclear. If its https is it going to fetch it every time the code is compiled? If its local will it do it every time?

  • avatar~clovercommented · 2 years ago
    Owner

    it will use the same mechanism for remote imports: caching forever using a lockfile to guarantee reproducibility

  • avatar~jeff-hykincommented · 2 years ago
    Author

    And for local stuff it just reads it every time?

  • avatar~lino-levancommented · 2 years ago

    I think the gameplan is have it cache forever for local stuff as well.

  • avatar~clovercommented · 2 years ago
    Owner

    the same as imports, when you change the fetched file, the code depending on it re-compiles. @import is, at a theory level, a wrapper on top of what @fetch does (in reality it will probably be it's own code path)