From 71d39b13b3e7adb054dbb2ca8ce03690aee075a3 Mon Sep 17 00:00:00 2001 From: Dannii Willis Date: Thu, 12 Dec 2024 12:08:56 +1000 Subject: [PATCH] Build with ENVIRONMENT=node,web, so that the .wasm doesn't have to be manually loaded --- .github/workflows/build-and-test.yml | 2 +- bin/emglken.js | 7 +------ src/common.cmake | 2 +- src/preamble.js | 4 ++-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 0e06346..f75f106 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -21,7 +21,7 @@ jobs: needs: build strategy: matrix: - node: [20, 22] + node: [20, 22, 23] name: test (Node v${{ matrix.node }}) runs-on: ubuntu-latest steps: diff --git a/bin/emglken.js b/bin/emglken.js index c17b941..71b876a 100755 --- a/bin/emglken.js +++ b/bin/emglken.js @@ -11,8 +11,6 @@ https://github.com/curiousdannii/emglken */ -import fs from 'fs' - import minimist from 'minimist' import {CheapAsyncDialog, CheapGlkOte, RemGlk} from '../build/asyncglk.js' @@ -87,7 +85,6 @@ async function run() Dialog, GlkOte, } - const wasmBinary = fs.readFileSync(new URL(`../build/${format.id}.wasm`, import.meta.url)) process.on('unhandledRejection', error => { if (error.name !== 'ExitStatus' || error.message !== 'Program terminated with exit(0)') { @@ -97,9 +94,7 @@ async function run() }) const engine = (await import(`../build/${format.id}.js`)).default - const vm = await engine({ - wasmBinary, - }) + const vm = await engine() vm.start(options) } diff --git a/src/common.cmake b/src/common.cmake index aa31ddd..a84bcc7 100644 --- a/src/common.cmake +++ b/src/common.cmake @@ -34,7 +34,7 @@ function(emglken_vm target) # Output options --minify 0 --profiling-funcs - -sENVIRONMENT=web + -sENVIRONMENT=node,web -sEXPORT_ES6=1 -sMODULARIZE=1 # Optimisations diff --git a/src/preamble.js b/src/preamble.js index 16ae9e8..6aa2e54 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -47,6 +47,6 @@ function accept(data) { // And now some things just to patch over Emscripten's lack of a none environment. These could probably be removed if https://github.com/emscripten-core/emscripten/issues/12184 ever gets implemented // Add an importScripts function to prevent an assertion error -function importScripts() {} +//function importScripts() {} // Fake locateFile so that Lectrote doesn't get tripped up on import.meta.url not being handled in CJS properly -Module['locateFile'] = function() {} \ No newline at end of file +//Module['locateFile'] = function() {} \ No newline at end of file