@@ -2501,7 +2501,7 @@ def generate_traditional_runtime_html(target, options, js_target, target_basenam
25012501 var filename = '%s';
25022502 if ((',' + window.location.search.substr(1) + ',').indexOf(',noProxy,') < 0) {
25032503 console.log('running code in a web worker');
2504- ''' % get_subresource_location (proxy_worker_filename )) + worker_js + '''
2504+ ''' % get_subresource_location_js (proxy_worker_filename )) + worker_js + '''
25052505 } else {
25062506 console.log('running code on the main thread');
25072507 var fileBytes = tryParseAsDataURI(filename);
@@ -2569,7 +2569,7 @@ def generate_traditional_runtime_html(target, options, js_target, target_basenam
25692569 // Current browser supports Wasm, proceed with loading the main JS runtime.
25702570 loadMainJs();
25712571 }
2572- ''' % (script .inline , get_subresource_location (wasm_target ) + '.js' )
2572+ ''' % (script .inline , get_subresource_location_js (wasm_target + '.js' ) )
25732573
25742574 shell = do_replace (shell , '{{{ SCRIPT }}}' , script .replacement ())
25752575 shell = shell .replace ('{{{ SHELL_CSS }}}' , utils .read_file (utils .path_from_root ('src/shell.css' )))
@@ -2645,7 +2645,7 @@ def generate_html(target, options, js_target, target_basename, wasm_target):
26452645def generate_worker_js (target , js_target , target_basename ):
26462646 if settings .SINGLE_FILE :
26472647 # compiler output is embedded as base64 data URL
2648- proxy_worker_filename = get_subresource_location (js_target )
2648+ proxy_worker_filename = get_subresource_location_js (js_target )
26492649 else :
26502650 # compiler output goes in .worker.js file
26512651 move_file (js_target , shared .replace_suffix (js_target , get_worker_js_suffix ()))
@@ -2958,13 +2958,17 @@ def move_file(src, dst):
29582958
29592959
29602960# Returns the subresource location for run-time access
2961- def get_subresource_location (path ):
2961+ def get_subresource_location (path , mimetype = 'application/octet-stream' ):
29622962 if settings .SINGLE_FILE :
2963- return 'data:application/octet-stream ;base64,' + base64_encode (path )
2963+ return f 'data:{ mimetype } ;base64,{ base64_encode (path )} '
29642964 else :
29652965 return os .path .basename (path )
29662966
29672967
2968+ def get_subresource_location_js (path ):
2969+ return get_subresource_location (path , 'text/javascript' )
2970+
2971+
29682972@ToolchainProfiler .profile ()
29692973def package_files (options , target ):
29702974 rtn = []
0 commit comments