WASM dependencies are not cached
roj1512 opened this issue · comments
The WASM dependencies that are required to build projects are not cached, hence redownloaded every time a build is made.
Hey @roj1512 thanks for reporting, are these dependencies of your project?
I've found WASM isn't cached correctly with Deno (probably a bug to be fixed on their end to be honest, although haven't dived into it too much)
What I've ended up doing, in Ultra in particular is using https://github.com/denosaurs/cache to cache the WASM dependency. An example from Ultra below.
import init, {
transform,
} from "https://esm.sh/@swc/wasm-web@1.3.11/wasm-web.js";
import { cache } from "https://deno.land/x/cache@0.2.13/mod.ts";
import { toFileUrl } from "https://deno.land/std/path/mod.ts";
const fileToCache = await cache(
"https://esm.sh/@swc/wasm-web@1.3.11/wasm-web_bg.wasm",
);
await init(toFileUrl(fileToCache.path));
No, Ultra's dependencies.
Ah I see! We probably need to open an issue on deno_graph, as they don't allow you to initialize the module with a custom WASM path, which we need to be able to cache that WASM dep.
I've opened a PR which will allow us to do this! denoland/deno_graph#199