Closed ducan-ne closed 6 months ago
As mentioned in caches issue, this is not common and can be solved when we implemented new Vite api For who need this in near future, I managed a workaround for this, it use nodejs api in dev server and import directly wasm in production version, leave the work to wrangler will compile and translate it.
if (import.meta.env.DEV) {
const fs = await import('node:fs/promises')
await initWasm(await fs.readFile(`${import.meta.dirname}/resvg.wasm`))
const yoga = await initYoga(await fs.readFile(`${import.meta.dirname}/yoga.wasm`))
init(yoga)
}
if (import.meta.env.PROD) {
const resvg = await import('./resvg.wasm' as any)
const yoga = await import('./yoga.wasm' as any)
await initWasm(resvg.default)
const yogaInstance = await initYoga(yoga.default)
init(yogaInstance)
}
Hi, do we have any plans to support importing WASM in the Cloudflare adapter?