@@ -3229,8 +3229,7 @@ def phase_final_emitting(options, state, target, wasm_target, memfile):
32293229
32303230 if settings .MODULARIZE :
32313231 modularize ()
3232-
3233- if settings .USE_CLOSURE_COMPILER :
3232+ elif settings .USE_CLOSURE_COMPILER :
32343233 module_export_name_substitution ()
32353234
32363235 # Run a final optimization pass to clean up items that were not possible to
@@ -3863,7 +3862,10 @@ def modularize():
38633862 shared .target_environment_may_be ('web' ):
38643863 async_emit = 'async '
38653864
3866- return_value = settings .EXPORT_NAME
3865+ # Return ths incoming moduleArg. This is is equeivielt to the `Module` var within the
3866+ # generated code is not effected by closure minifiection so we can references in the
3867+ # the return statement.
3868+ return_value = 'moduleArg'
38673869 if settings .WASM_ASYNC_COMPILATION :
38683870 return_value += '.ready'
38693871 if not settings .EXPORT_READY_PROMISE :
@@ -3874,7 +3876,7 @@ def modularize():
38743876 diagnostics .warning ('emcc' , 'EXPORT_NAME should not be named "config" when targeting Safari' )
38753877
38763878 src = '''
3877- %(maybe_async)sfunction(%(EXPORT_NAME)s = {}) {
3879+ %(maybe_async)sfunction(moduleArg = {}) {
38783880
38793881%(src)s
38803882
@@ -3883,7 +3885,6 @@ def modularize():
38833885%(capture_module_function_for_audio_worklet)s
38843886''' % {
38853887 'maybe_async' : async_emit ,
3886- 'EXPORT_NAME' : settings .EXPORT_NAME ,
38873888 'src' : src ,
38883889 'return_value' : return_value ,
38893890 # Given the async nature of how the Module function and Module object come into existence in AudioWorkletGlobalScope,
@@ -3945,6 +3946,7 @@ def modularize():
39453946
39463947
39473948def module_export_name_substitution ():
3949+ assert not settings .MODULARIZE
39483950 global final_js
39493951 logger .debug (f'Private module export name substitution with { settings .EXPORT_NAME } ' )
39503952 src = read_file (final_js )
0 commit comments