Skip to content

Commit

Permalink
optimize build
Browse files Browse the repository at this point in the history
  • Loading branch information
ceifa committed Jan 18, 2025
1 parent 6e8fcc7 commit 94e84fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 2 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -32,6 +30,7 @@ emcc \
'locateFile', \
'preRun'
]" \
-s ENVIRONMENT="web,worker,node" \
-s STRICT_JS=0 \
-s MODULARIZE=1 \
-s ALLOW_TABLE_GROWTH=1 \
Expand Down
12 changes: 12 additions & 0 deletions test/initialization.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LuaFactory } from '../dist/index.js'
import { expect } from 'chai'

describe('Initialization', () => {
it('create engine should succeed', async () => {
Expand All @@ -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)
})
})

0 comments on commit 94e84fb

Please sign in to comment.