@@ -2497,7 +2497,7 @@ def generate_traditional_runtime_html(target, options, js_target, target_basenam
24972497 var filename = '%s';
24982498 if ((',' + window.location.search.substr(1) + ',').indexOf(',noProxy,') < 0) {
24992499 console.log('running code in a web worker');
2500- ''' % get_subresource_location (proxy_worker_filename )) + worker_js + '''
2500+ ''' % get_subresource_location_js (proxy_worker_filename )) + worker_js + '''
25012501 } else {
25022502 console.log('running code on the main thread');
25032503 var fileBytes = tryParseAsDataURI(filename);
@@ -2565,7 +2565,7 @@ def generate_traditional_runtime_html(target, options, js_target, target_basenam
25652565 // Current browser supports Wasm, proceed with loading the main JS runtime.
25662566 loadMainJs();
25672567 }
2568- ''' % (script .inline , get_subresource_location (wasm_target ) + '.js' )
2568+ ''' % (script .inline , get_subresource_location_js (wasm_target + '.js' ) )
25692569
25702570 shell = do_replace (shell , '{{{ SCRIPT }}}' , script .replacement ())
25712571 shell = shell .replace ('{{{ SHELL_CSS }}}' , utils .read_file (utils .path_from_root ('src/shell.css' )))
@@ -2641,7 +2641,7 @@ def generate_html(target, options, js_target, target_basename, wasm_target):
26412641def generate_worker_js (target , js_target , target_basename ):
26422642 if settings .SINGLE_FILE :
26432643 # compiler output is embedded as base64 data URL
2644- proxy_worker_filename = get_subresource_location (js_target )
2644+ proxy_worker_filename = get_subresource_location_js (js_target )
26452645 else :
26462646 # compiler output goes in .worker.js file
26472647 move_file (js_target , shared .replace_suffix (js_target , get_worker_js_suffix ()))
@@ -2954,13 +2954,17 @@ def move_file(src, dst):
29542954
29552955
29562956# Returns the subresource location for run-time access
2957- def get_subresource_location (path ):
2957+ def get_subresource_location (path , mimetype = 'application/octet-stream' ):
29582958 if settings .SINGLE_FILE :
2959- return 'data:application/octet-stream ;base64,' + base64_encode (path )
2959+ return f 'data:{ mimetype } ;base64,{ base64_encode (path )} '
29602960 else :
29612961 return os .path .basename (path )
29622962
29632963
2964+ def get_subresource_location_js (path ):
2965+ return get_subresource_location (path , 'text/javascript' )
2966+
2967+
29642968@ToolchainProfiler .profile ()
29652969def package_files (options , target ):
29662970 rtn = []
0 commit comments