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

can't access property "__wbindgen_malloc" #104

Open
imjasonmiller opened this issue Mar 22, 2021 · 2 comments
Open

can't access property "__wbindgen_malloc" #104

imjasonmiller opened this issue Mar 22, 2021 · 2 comments

Comments

@imjasonmiller
Copy link

Hi,

I've been trying to get the example to work, but I'm receiving an error that I haven't been able to solve. I must have overlooked something.

Taking the example from the documentation:

index.js

import("./pkg").then((module) => {
  module.greet("42");
});

lib.rs

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
    fn alert(s: &str);
}

#[wasm_bindgen]
pub fn greet(name: &str) {
    alert(&format!("Hello, {:?}!", name))
}

Then running npm run serve, gives the following error in the browser's console:

TypeError: can't access property "__wbindgen_malloc", _index_bg_wasm__WEBPACK_IMPORTED_MODULE_0__ is undefined

Oddly enough, the following for index.js does appear to show the alert, but does nothing with the passed string to fn greet():

import * as wasm from "./pkg/index_bg.wasm";

async function main() {
  wasm.greet("42");
}

main();

A minimal, reproducible example and used dependencies can be found here:

I've tried both Firefox 87.0b9 (64-bit) and Google Chrome 89.0.4389.90 (64-bit).

Thank you for your time.

@GoogleFeud
Copy link

I'm having the exact same issue!

@GoogleFeud
Copy link

I managed to fix the issue by using an earlier version of webpack.

    "webpack": "^4.29.4",
    "webpack-cli": "^3.1.1"

This is probably an issue with webpack

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