From 94e84fb65c55f54f7a9e32182110536a0b6f2748 Mon Sep 17 00:00:00 2001 From: ceifa Date: Sat, 18 Jan 2025 10:00:34 -0300 Subject: [PATCH] optimize build --- build.sh | 5 ++--- test/initialization.test.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 3b420d9..7700926 100755 --- a/build.sh +++ b/build.sh @@ -9,9 +9,7 @@ if [ "$1" == "dev" ]; then extension="-O0 -g3 -s ASSERTIONS=1 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2" else - # TODO: This appears to be a bug in emscripten. Disable assertions when that bug is resolved or a workaround found. - # ASSERTIONS=1 required with optimisations and strict mode. https://github.com/emscripten-core/emscripten/issues/20721 - extension="-O3 --closure 1 -s ASSERTIONS=1" + extension="-O3 --closure 1" fi emcc \ @@ -32,6 +30,7 @@ emcc \ 'locateFile', \ 'preRun' ]" \ + -s ENVIRONMENT="web,worker,node" \ -s STRICT_JS=0 \ -s MODULARIZE=1 \ -s ALLOW_TABLE_GROWTH=1 \ diff --git a/test/initialization.test.js b/test/initialization.test.js index 584325a..72d1684 100644 --- a/test/initialization.test.js +++ b/test/initialization.test.js @@ -1,4 +1,5 @@ import { LuaFactory } from '../dist/index.js' +import { expect } from 'chai' describe('Initialization', () => { it('create engine should succeed', async () => { @@ -13,4 +14,15 @@ describe('Initialization', () => { traceAllocations: true, }) }) + + it('create with environment variables should succeed', async () => { + const env = { + ENV_TEST: 'test', + } + const engine = await new LuaFactory(undefined, env).createEngine() + + const value = await engine.doString('return os.getenv("ENV_TEST")') + + expect(value).to.be.equal(env.ENV_TEST) + }) })