@@ -794,10 +794,21 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
794794 if settings .MODULARIZE and settings .MODULARIZE not in [1 , 'instance' ]:
795795 exit_with_error (f'Invalid setting "{ settings .MODULARIZE } " for MODULARIZE.' )
796796
797+ def limit_incoming_module_api ():
798+ if options .oformat == OFormat .HTML and options .shell_path == DEFAULT_SHELL_HTML :
799+ # Out default shell.html file has minimal set of INCOMING_MODULE_JS_API elements that it expects
800+ default_setting ('INCOMING_MODULE_JS_API' , 'canvas,monitorRunDependencies,onAbort,onExit,print,setStatus' .split (',' ))
801+ else :
802+ default_setting ('INCOMING_MODULE_JS_API' , [])
803+
797804 if settings .MODULARIZE == 'instance' :
798805 diagnostics .warning ('experimental' , '-sMODULARIZE=instance is still experimental. Many features may not work or will change.' )
799806 if options .oformat != OFormat .MJS :
800807 exit_with_error ('emcc: MODULARIZE instance is only compatible with .mjs output files' )
808+ limit_incoming_module_api ()
809+ for s in ['wasmMemory' , 'INITIAL_MEMORY' ]:
810+ if s in settings .INCOMING_MODULE_JS_API :
811+ exit_with_error (f'emcc: { s } cannot be in INCOMING_MODULE_JS_API in MODULARIZE=instance mode' )
801812
802813 if options .oformat in (OFormat .WASM , OFormat .BARE ):
803814 if options .emit_tsd :
@@ -965,11 +976,7 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
965976 # are needed in this mode.
966977 default_setting ('AUTO_JS_LIBRARIES' , 0 )
967978 default_setting ('ALLOW_UNIMPLEMENTED_SYSCALLS' , 0 )
968- if options .oformat == OFormat .HTML and options .shell_path == DEFAULT_SHELL_HTML :
969- # Out default shell.html file has minimal set of INCOMING_MODULE_JS_API elements that it expects
970- default_setting ('INCOMING_MODULE_JS_API' , 'canvas,monitorRunDependencies,onAbort,onExit,print,setStatus' .split (',' ))
971- else :
972- default_setting ('INCOMING_MODULE_JS_API' , [])
979+ limit_incoming_module_api ()
973980
974981 if 'noExitRuntime' in settings .INCOMING_MODULE_JS_API :
975982 settings .DEFAULT_LIBRARY_FUNCS_TO_INCLUDE .append ('$noExitRuntime' )
0 commit comments