Skip to content

Commit 5e62fab

Browse files
committed
Store Module object in global scope in MINIMAL_RUNTIME builds
This is required for MODULARIZE and EXPORT_ES6 to work in combination with MINIMAL_RUNTIME.
1 parent 66f8a39 commit 5e62fab

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

test/test_browser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5747,6 +5747,8 @@ def test_full_js_library_strict(self):
57475747
'pthreads_and_closure': (['-pthread', '--closure', '1', '-Oz'],),
57485748
'minimal_runtime': (['-sMINIMAL_RUNTIME'],),
57495749
'minimal_runtime_pthreads_and_closure': (['-sMINIMAL_RUNTIME', '-pthread', '--closure', '1', '-Oz'],),
5750+
'minimal_runtime_es6': (['-sMINIMAL_RUNTIME', '-sEXPORT_ES6'],),
5751+
'minimal_runtime_es6_no_assertions': (['-sMINIMAL_RUNTIME', '-sEXPORT_ES6', '-sASSERTIONS=0'],),
57505752
'pthreads_es6': (['-pthread', '-sPTHREAD_POOL_SIZE=2', '-sEXPORT_ES6'],),
57515753
'es6': (['-sEXPORT_ES6'],),
57525754
})

tools/link.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,13 +2352,15 @@ def modularize():
23522352
'script_url_node': script_url_node,
23532353
'src': src,
23542354
}
2355-
# Given the async nature of how the Module function and Module object
2356-
# come into existence in AudioWorkletGlobalScope, store the Module
2357-
# function under a different variable name so that AudioWorkletGlobalScope
2358-
# will be able to reference it without aliasing/conflicting with the
2359-
# Module variable name.
2360-
if settings.AUDIO_WORKLET and settings.MODULARIZE:
2361-
src += f'globalThis.AudioWorkletModule = {settings.EXPORT_NAME};'
2355+
2356+
# Given the async nature of how the Module function and Module object
2357+
# come into existence in AudioWorkletGlobalScope, store the Module
2358+
# function under a different variable name so that AudioWorkletGlobalScope
2359+
# will be able to reference it without aliasing/conflicting with the
2360+
# Module variable name. This should happen even in MINIMAL_RUNTIME builds
2361+
# for MODULARIZE and EXPORT_ES6 to work correctly.
2362+
if settings.AUDIO_WORKLET and settings.MODULARIZE:
2363+
src += f'globalThis.AudioWorkletModule = {settings.EXPORT_NAME};'
23622364

23632365
# Export using a UMD style export, or ES6 exports if selected
23642366
if settings.EXPORT_ES6:

0 commit comments

Comments
 (0)