Phisn
CDCloudflare Developers
•Created by Phisn on 9/8/2023 in #workers-help
Webassembly in libraries not correctly loading
I am currently working on a project using the npm package "@dimforge/rapier2d". The package can be used in two ways, either using a bundler that resolves the .wasm dependency it is using internally or using the package "@dimforge/rapier2d" where it loads itself from a base64 string.
I am currently using the first version. The code is shared between a frontend vite project and the cloudflare worker project. It works flawlessly with vite. The recommended way of loading the library is using
import("@dimforge/rapier2d")
where it internally loads the .wasm file using import * as wasm from './rapier_wasm2d_bg.wasm';
(the wasm file does reside in the moment of compilation in the node_modules directory).
When I try to use this library with cloudflare workers it seems to resolve the promise import("@dimforge/rapier2d")
but webassembly functions are not correctly defined and I get an is not a function
error for some internal (in rapier) intergration function.
I also previously tried to use the compat package but only get a blocked by embeddeder
error, because WebAssebmly.instantiate([...]) is not allowed for manual loaded data.
How can I correctly load the webassembly parts from packages I am using or disable the eval content security policy?4 replies