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 start wasm #68

Open
PitiBouchon opened this issue Apr 8, 2024 · 1 comment · May be fixed by #69
Open

Can't start wasm #68

PitiBouchon opened this issue Apr 8, 2024 · 1 comment · May be fixed by #69

Comments

@PitiBouchon
Copy link

I tried wasm-pack and xtask-wasm and I found one difference in the .js file generated.
In the app.js of xtask-wasm:

async function __wbg_init(input) {
    if (wasm !== undefined) return wasm;


    const imports = __wbg_get_imports();

    if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
        input = fetch(input);
    }

    __wbg_init_memory(imports);

    const { instance, module } = await __wbg_load(await input, imports);

    return __wbg_finalize_init(instance, module);
}

while in app.js of wasm-pack :

async function __wbg_init(input) {
    if (wasm !== undefined) return wasm;

    if (typeof input === 'undefined') {
        input = new URL('app_bg.wasm', import.meta.url);
    }
    const imports = __wbg_get_imports();

    if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
        input = fetch(input);
    }

    __wbg_init_memory(imports);

    const { instance, module } = await __wbg_load(await input, imports);

    return __wbg_finalize_init(instance, module);
}

And witheout this if my app doesn't work

@PitiBouchon
Copy link
Author

PitiBouchon commented Apr 21, 2024

After some investigation it looks like wasm-bindgen <path to game.wasm> --out-dir dist\ --typescript --target web is generating something different that :

Bindgen::new()
    .typescript(true)
    .input_path(input_path)
    .web(true)
    .expect("web have panic")
    .debug(false)
    .generate_output()
    .expect("could not generate Wasm bindgen file");

@PitiBouchon PitiBouchon linked a pull request Apr 21, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant