diff --git a/Cargo.toml b/Cargo.toml index 4bf125a..0ad0e82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-web" -version = "0.6.26" +version = "0.6.27" authors = ["Jan Bujak "] repository = "https://github.com/koute/cargo-web" homepage = "https://github.com/koute/cargo-web" diff --git a/src/wasm_runtime_standalone.js b/src/wasm_runtime_standalone.js index 960f8f6..0dc5d5d 100644 --- a/src/wasm_runtime_standalone.js +++ b/src/wasm_runtime_standalone.js @@ -25,7 +25,11 @@ if( typeof Rust === "undefined" ) { var wasm_instance = new WebAssembly.Instance( mod, instance.imports ); return instance.initialize( wasm_instance ); } else { - var file = fetch( "{{{wasm_filename}}}", {credentials: "same-origin"} ); + var jsurl = new URL( document.querySelector( 'script[src$="{{{module_name}}}.js"]' ).src ); + var jspath = jsurl.pathname; + var dotpos = jspath.lastIndexOf( "." ); + var wasmpath = jspath.substr( 0, dotpos ) + ".wasm"; + var file = fetch( wasmpath, {credentials: "same-origin"} ); var wasm_instance = ( typeof WebAssembly.instantiateStreaming === "function" ? WebAssembly.instantiateStreaming( file, instance.imports )