-
Notifications
You must be signed in to change notification settings - Fork 12
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
`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
8e4fc5a
commit 07b6aa7
Showing
12 changed files
with
201 additions
and
54 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
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.