@@ -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.
@@ -1033,7 +1030,7 @@ def generate_js(data_target, data_files, metadata):
10331030 # we need to find the datafile in the same dir as the html file
10341031
10351032 code += '''
1036- if (! Module['preloadResults']) Module['preloadResults'] = {};\n '''
1033+ Module['preloadResults'] ?? = {};\n '''
10371034
10381035 if options .use_preload_cache :
10391036 code += '''
@@ -1099,8 +1096,7 @@ def generate_js(data_target, data_files, metadata):
10991096 if (Module['calledRun']) {
11001097 runWithFS(Module);
11011098 } else {
1102- if (!Module['preRun']) Module['preRun'] = [];
1103- Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
1099+ (Module['preRun'] ??= []).push(runWithFS); // FS is not initialized yet, wait for it
11041100 }\n '''
11051101
11061102 if options .separate_metadata :
@@ -1139,8 +1135,7 @@ def generate_js(data_target, data_files, metadata):
11391135 if (Module['calledRun']) {
11401136 runMetaWithFS();
11411137 } else {
1142- if (!Module['preRun']) Module['preRun'] = [];
1143- Module["preRun"].push(runMetaWithFS);
1138+ (Module['preRun'] ??= []).push(runMetaWithFS);
11441139 }\n ''' % {'node_support_code' : node_support_code , 'metadata_file' : os .path .basename (options .jsoutput + '.metadata' )}
11451140 else :
11461141 ret += '''
0 commit comments