2

I'm trying to host a React app in webview which uses a compiled Rust -> WebAssembly module.

I get this error:

Unhandled promise rejection: TypeError: URL is not valid or contains user credentials.

The WASM module gets called in one of the components:

const { mymod } = require("../../wasm/mymod");

Then I use webpack to bundle it all.

const webpackConfig = {
  entry: "./frontend/bootstrap.js",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bundle.js",
  },
  mode: "development",
  module: {
    rules: [
    ]
  },
  plugins: [
    new HtmlWebPackPlugin({
      template: "./frontend/index.html"
    }),
    new MiniCssExtractPlugin(),
  ]
};

Then I load it in webview:

fn main() {
    let html = format!(r#"...");

    web_view::builder()
        .title("my app")
        .content(Content::Html(html))
        .size(320, 480)
        .resizable(true)
        .debug(true)
        .user_data(())
        .invoke_handler(|_webview, _arg| Ok(()))
        .run()
        .unwrap();
}

The error in the JavaScript debugger leads to this line of code:

var req = fetch(__webpack_require__.p + "" + {"./frontend/wasm/mymod_bg.wasm":"31335016d485c8fcb290"}[wasmModuleId] + ".module.wasm")

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.