The WASM32-compiler modes doesn't export routines. lazarus / 68-Other OS ---------------------------------------------------------------------- jddev · 2025-04-13 23:03 Hi, all. WASM support is quite attractive to me, but documentation is rare at this point. For testing purposes I want to embed following code on my website: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i library sitehelpers; uses sysutils; function visitedAt(): AnsiString;begin      visitedAt := DateTimeToStr(Now, false) + ' (Systemtime)';end; exports        visitedAt;        End.  Some explanations: a) Due to the fact the "embedded" target only compiles libraries and units I choose "library", this generates a binary withaout wasm- extention. b) neither the direct saved wat (-a switch) nor the reversed one (wasm2wat) contain an export statement for vsitedAt(), but a complicated mangled name for it. Both files are provided in the attached archive. c) compiling it as a program in WASI-mode builds an executble (with .wasm extention) , which runs in wasmtime but doesn't work in my browsers. Thanks in advance and greets, Jonathan ---------------------------------------------------------------------- PierceNg · 2025-04-14 03:25 Quote from: jddev on April 14, 2025, 01:03:38 amc) compiling it as a program in WASI-mode builds an executble (with .wasm extention) , which runs in wasmtime but doesn't work in my browsers. You need to set up the .wasm for the browser environment with Javascript. See pas2js Wasm examples implementing driver programs in Pascal that get transpiled to Javascript, that load other compiled-to- Wasm Pascal programs. Also my game of life demo. ---------------------------------------------------------------------- jddev · 2025-04-14 11:39 Hi. Okay, this explains why it doesn't work through the WASM-JS interface, described at https://developer.mozilla.org/de/docs/WebAssembly/Referen ce/JavaScript_interface. I'm strugglling with the configuration of pas2js for now. It doesn't seem to parse paths in the same way the standard compiler does and doesn't accept globs/wildcards like '*' in such paths. Greets, Jonathan ---------------------------------------------------------------------- PierceNg · 2025-04-14 14:47 Quote from: jddev on April 14, 2025, 01:39:04 pmHi. Okay, this explains why it doesn't work through the WASM-JS interface, described at https://developer.mozilla.org/de/docs/WebAssembly/Referen ce/JavaScript_interface. I'm strugglling with the configuration of pas2js for now. It doesn't seem to parse paths in the same way the standard compiler does and doesn't accept globs/wildcards like '*' in such paths. Plain Javascript works too. See https://github.com/PierceNg/wasm- demo/blob/pn/lyff/htdocs/main.js ---------------------------------------------------------------------- jddev · 2025-04-14 18:23 Hi. I found the root of the problem. The generated wasm d oesn't report the MIME-Type to the Browser and so the promise in the loading code can't be fullfilled. If I get this fixed, the wasm should load correctly with the WASM-JS API posted above. Greets, Jonathan