Ways to cleanly import a trunk generated wasm/js file into a js file? #929
Unanswered
vjackson725
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I want to import the (js wrapped) wasm files generated by trunk in other JavaScript files. Unfortunately, cache control hashes mean I can't predict the name to import into the
js
file using theimport ... from "..."
syntax statically. If I knew the name at runtime, I could use a dynamic import. The best solution I've come up with is just to turn off the cache control (usingfilehash = false
), but that seems a bit too heavy-handed a solution. This is for use in a service worker, so unfortunately I don't have access to thewindow.wasmBindings
.A good solution to this may need trunk to be extended. This problem is similar to Issue #405, and many discussed solutions there would be applicable here; in particular, generating an asset manifest. A simple idea for an incremental improvement would just be to be able to selectively disable cache control hashes with an option on the
<link data-trunk ... />
.Beta Was this translation helpful? Give feedback.
All reactions