The generated script from wrangler keeps re-instantiating the WASM module every time the request is processed. Instead, let's switch to using the much, much better Webpack support for WASM.
13 lines
288 B
JavaScript
13 lines
288 B
JavaScript
addEventListener('fetch', event => {
|
|
event.respondWith(handleRequest(event.request))
|
|
})
|
|
|
|
/**
|
|
* Fetch and log a request
|
|
* @param {Request} request
|
|
*/
|
|
async function handleRequest(request) {
|
|
const rust = await import("./pkg/index");
|
|
return await rust.handle_request_rs(request);
|
|
}
|