-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: accept WebAssembly.Module, Response inputs (#32)
`createPlugin` now accepts two additional manifest types (`response` and `module`) as well as `Response` and `WebAssembly.Module`. There are four goals here: 1. Allow us to target the Cloudflare Workers platform. CF Workers only support loading Wasm via `import` statements; these resolve to `WebAssembly.Module` objects, which means we need to allow users to pass `Module`s in addition to our other types. 2. Play nicely with V8's [Wasm caching][1]; in particular V8 will use metadata from the `Response` to build a key for caching the results of Wasm compilation. 3. This sets us up to implement [Wasm linking][2] by allowing us to introspect plugin modules imports and exports before instantiation. 4. And finally, resolving to modules instead of arraybuffers allows us to add [hooks for observe-sdk][3] (especially in advance of adding [thread pooling][4]). Because Bun lacks support for `WebAssembly.compileStreaming` and `Response.clone()`, we provide an alternate implementation for converting a response to a module and its metadata. One caveat is that there's no way to get the source bytes of a `WebAssembly.Module`, so `{module}` cannot be used with `{hash}` in a `Manifest`. Fixes #9 [1]: https://v8.dev/blog/wasm-code-caching#stream [2]: #29 [3]: #3 [4]: #31
- Loading branch information
1 parent
0aac0c6
commit 630fcd6
Showing
12 changed files
with
241 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.