Closed voxelstack closed 9 months ago
Also experiencing this with Sveltekit
any reproduce project?
Please test it with the latest version of the plugin. See #23.
Closing since no response.
@Menci I gave up lol came back to it still getting this error. Here's a simple repo I just setup https://github.com/Antonio-Bennett/VisualizedAlgos
Also meet this issue, is there a solution now?
Sorry I'll take a look on this
Just checked your repo @Antonio-Bennett. It's the same as https://github.com/Menci/vite-plugin-wasm/issues/27, which is a bug of wasm-pack https://github.com/rustwasm/wasm-bindgen/commit/721c86c3467750bf2a46bf85941e6c211ae9e87a, not this plugin.
See https://github.com/rustwasm/wasm-pack/issues/1235 for the issue and https://github.com/rustwasm/wasm-pack/pull/1237 for a fix.
@SKTT1Ryze @voxelstack Please also check you projects. If there're different issues in your project, send to me to investigate.
In the meantime you can disable manually treeshaking for the module:
export default defineConfig({
plugins: [wasm(), topLevelAwait()],
build: {
rollupOptions: {
plugins: [
{
name: "disable-treeshake",
transform(code, id) {
if (id.includes("MYMODULE")) {
return { moduleSideEffects: "no-treeshake" };
}
},
},
],
},
},
});
@Menci Solved in my case, i just didn't load the*_bg.wasm
file with init
function.
@Menci Solved in my case, i just didn't load the
*_bg.wasm
file withinit
function.
My project: https://github.com/DarkNeos/neos-ts
I had a NextJS project setup where I would build a rust library with
wasm-pack
, install it withfile:wasm-bindgen-module
, setasyncWebAssembly
on the Webpack config and then import and use it like this:I am now moving over to SvelteKit and the "(aka. Webpack's asyncWebAssembly)" led me to believe I would be able to do the same but when I do
onMount(() => f())
, I getCannot read properties of undefined (reading 'f')
.Here's my
vite.config.js
:Am I missing anything?