Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kalk-component: Failed to execute 'compile' on 'WebAssembly' #91

Open
BearToCode opened this issue Jun 17, 2022 · 5 comments
Open

kalk-component: Failed to execute 'compile' on 'WebAssembly' #91

BearToCode opened this issue Jun 17, 2022 · 5 comments

Comments

@BearToCode
Copy link

Hello,
I'm trying to include the Kalk web component in a Tauri app with a React front-end. However, I keep getting the following error, which comes directly from the component bundle.js:

TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.

That's how I included Kalk:

import { KalkCalculator, ConsoleLine } from "@paddim8/kalk-component";


const ToolsWindow = () => {
  return (
      <div className="kalk">
        <kalk-calculator>
          <console-line>kalker</console-line>
          <console-line>
            <span className="hint">Type 'help' for instructions.</span>
          </console-line>
        </kalk-calculator>
      </div>
  )
}

My project.json looks like that

"dependencies": {
    "@paddim8/kalk-component": "^2.0.0",
    "@tauri-apps/api": "^1.0.0-rc.6",
    "react": "^18.1.0",
    "react-dom": "^18.1.0",
    "react-scripts": "5.0.1",
    ...
  },

Your work is really cool and I'd really like to use it in my project.

@PaddiM8
Copy link
Owner

PaddiM8 commented Jun 17, 2022

Hmm that's strange. Perhaps something you're using doesn't support WebAssembly? What bundler are you using?

@BearToCode
Copy link
Author

I've not installed any bundler, there should only be a Tauri Bundler for the Rust side of the app (at least that's what I understood reading the documentation).

@BearToCode
Copy link
Author

BearToCode commented Jun 17, 2022

I've looked for help on the Tauri community and they sent me what should be a list of mime types:
https://github.com/tauri-apps/tauri/blob/dev/core/tauri-runtime/src/http/mime_type.rs

If yours is not in the list I can file an issue on their side.

Also: do I need Webpack and Svelte to use the module?

@PaddiM8
Copy link
Owner

PaddiM8 commented Jun 17, 2022

Aha I see. I guess missing support for the mime type could be it, since I haven't seen that error in other situations. You shouldn't need Webpack or Svelte to use the module. The website (kalker.xyz) doesn't use anything like that! The library should basically just provide a regular web component.

@BearToCode
Copy link
Author

Apparently there are ways to import the .wasm that do not check for the mime type:

https://stackoverflow.com/a/52732108/14065064

If you considered applying that change it would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants