You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading to astro v10 (from v8), my wasm module imports stopped working. After investigating the tests, I discovered that the differences seems to be that in my build, a shared file that imports a wasm module is used both within an SSR route and a SSG route. When this scenario occurs, the astro build ends in an obscure error:
file:///Users/adrianlyjak/dev/withastro-adapters/packages/cloudflare/test/fixtures/wasm/dist/_worker.js/chunks/hybrid_DqxhzLZ0.mjs?time=1714010209741
Unknown file extension ".wasm" for /Users/adrianlyjak/dev/withastro-adapters/packages/cloudflare/test/fixtures/wasm/dist/_worker.js/add.1ot1qwu.wasm
Stack trace:
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
at defaultLoad (node:internal/modules/esm/load:143:22)
at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:45)
This change modifies the tests to reproduce the error
It seems like there's a flaw in the logic of splitting up a wasm import between pre-rendered and server rendered mode, it could be both!
constisPrerendered=Object.keys(chunk.modules).some((moduleId)=>this.getModuleInfo(moduleId)?.meta?.astro?.pageOptions?.prerender===true);letfinal=code;// SSRif(!isPrerendered){// replace with .wasm for workerd environments}// SSGif(isPrerendered){// replace with .wasm.mjs for nodelike environments}
I'm thinking that this needs to be approached some other way. The best I can think of is to build the code for node while still emitting bundled assets, and then do a last minute minor modification to update the imports to point to the asset for cloudflare workers
What's the expected result?
You should be able to import shared wasm modules like before
Astro Info
Describe the Bug
After upgrading to astro v10 (from v8), my wasm module imports stopped working. After investigating the tests, I discovered that the differences seems to be that in my build, a shared file that imports a wasm module is used both within an SSR route and a SSG route. When this scenario occurs, the astro build ends in an obscure error:
This change modifies the tests to reproduce the error
It seems like there's a flaw in the logic of splitting up a wasm import between pre-rendered and server rendered mode, it could be both!
I'm thinking that this needs to be approached some other way. The best I can think of is to build the code for node while still emitting bundled assets, and then do a last minute minor modification to update the imports to point to the asset for cloudflare workers
What's the expected result?
You should be able to import shared wasm modules like before
Link to Minimal Reproducible Example
main...adrianlyjak:withastro-adapters:shared-wasm
Participation
The text was updated successfully, but these errors were encountered: