@@ -607,10 +607,7 @@ def generate_js(data_target, data_files, metadata):
607607 var Module = typeof %(EXPORT_NAME)s != 'undefined' ? %(EXPORT_NAME)s : {};\n ''' % {"EXPORT_NAME" : options .export_name }
608608
609609 ret += '''
610- if (!Module['expectedDataFileDownloads']) {
611- Module['expectedDataFileDownloads'] = 0;
612- }
613-
610+ Module['expectedDataFileDownloads'] ??= 0;
614611 Module['expectedDataFileDownloads']++;
615612 (() => {
616613 // Do not attempt to redownload the virtual filesystem data when in a pthread or a Wasm Worker context.
@@ -1027,7 +1024,7 @@ def generate_js(data_target, data_files, metadata):
10271024 # we need to find the datafile in the same dir as the html file
10281025
10291026 code += '''
1030- if (! Module['preloadResults']) Module['preloadResults'] = {};\n '''
1027+ Module['preloadResults'] ?? = {};\n '''
10311028
10321029 if options .use_preload_cache :
10331030 code += '''
@@ -1093,8 +1090,7 @@ def generate_js(data_target, data_files, metadata):
10931090 if (Module['calledRun']) {
10941091 runWithFS(Module);
10951092 } else {
1096- if (!Module['preRun']) Module['preRun'] = [];
1097- Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
1093+ (Module['preRun'] ??= []).push(runWithFS); // FS is not initialized yet, wait for it
10981094 }\n '''
10991095
11001096 if options .separate_metadata :
@@ -1118,8 +1114,7 @@ def generate_js(data_target, data_files, metadata):
11181114 if (Module['calledRun']) {
11191115 runMetaWithFS();
11201116 } else {
1121- if (!Module['preRun']) Module['preRun'] = [];
1122- Module["preRun"].push(runMetaWithFS);
1117+ (Module['preRun'] ??= []).push(runMetaWithFS);
11231118 }\n ''' % {'metadata_file' : os .path .basename (options .jsoutput + '.metadata' )}
11241119 else :
11251120 _metadata_template = '''
0 commit comments