Ways to cleanly import a trunk generated wasm/js file into a js file? #929
Unanswered
vjackson725
asked this question in
Q&A
Replies: 1 comment
-
I would like to know the answer to this also. Have exactly the same problem... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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