exhibitionist-digital / ultra

Zero-Legacy Deno/React Suspense SSR Framework
https://ultrajs.dev
MIT License
2.99k stars 66 forks source link

WASM dependencies are not cached #222

Closed rojvv closed 1 year ago

rojvv commented 1 year ago

The WASM dependencies that are required to build projects are not cached, hence redownloaded every time a build is made.

rojvv commented 1 year ago

This and #221 increase the time needed to build and deploy a lot.

deckchairlabs commented 1 year ago

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));
rojvv commented 1 year ago

No, Ultra's dependencies.

rojvv commented 1 year ago

First build

image

Second build with connection removed but .ultra/ persisted

image

deckchairlabs commented 1 year ago

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.

deckchairlabs commented 1 year ago

https://github.com/denoland/deno_graph/issues/198

deckchairlabs commented 1 year ago

I've opened a PR which will allow us to do this! https://github.com/denoland/deno_graph/pull/199