update example nodejs scripts

This commit is contained in:
bytedream 2025-03-03 16:49:07 +01:00
parent 28001a2040
commit 10eb71bb11
2 changed files with 26 additions and 2 deletions

View File

@ -1,5 +1,17 @@
async function main() {
const wasm = await import('./target/wasm32-unknown-emscripten/debug/example-binary.js');
let wasm;
for (const buildType of ['release', 'debug']) {
try {
wasm = await import(`./target/wasm32-unknown-emscripten/${buildType}/example-binary.js`);
break;
} catch (e) {
if (e.code !== 'ERR_MODULE_NOT_FOUND') throw e;
}
}
if (!wasm) {
throw new Error('Rust wasm binary not built');
}
const module = {
print: (str) => console.log(str),
printErr: (str) => console.error(str),

View File

@ -1,5 +1,17 @@
async function main() {
const wasm = await import('./target/wasm32-unknown-emscripten/debug/example-library.js');
let wasm;
for (const buildType of ['release', 'debug']) {
try {
wasm = await import(`./target/wasm32-unknown-emscripten/${buildType}/example-library.js`);
break;
} catch (e) {
if (e.code !== 'ERR_MODULE_NOT_FOUND') throw e;
}
}
if (!wasm) {
throw new Error('Rust wasm binary not built');
}
const module = {
print: (str) => console.log(str),
printErr: (str) => console.error(str),