EMScriptenSvelte Svelte Themes

Emscriptensvelte

EMScripten + Svelte test

Svelte + EMScripten

VS Code + Svelte.

EMScripten setup

Go follow the EMScripten Install Guide

Bascially the TLDR (on Windows):

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
emsdk install latest
emsdk activate latest
emsdk_env.bat

cd ..\wasm
build.bat

Quick dev

npm i     # or pnpm i
npm run watch

Open "wasm/hello.cpp"

Now go to "dist/preview.html" and right click "Show Preview"

Edit some of the hello.cpp and enjoy !

Run the project

npm i     # or pnpm i
npm run dev

Open in your browser : http://localhost:5173/

Advanced stuff

Interesting part is the "wasm/hello.cpp" file. Take a look at it !

Recommanded to read https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html to understand how the sdk is linked on JS

Top categories

Loading Svelte Themes