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
Unable to use WebAssembly inside a Next.js project #27083
Comments
I've gotten it to work with the latest nextjs version ( import React, { ReactElement, useCallback } from "react";
export default function LazyJSONIndex(): ReactElement {
const getRefAndRunWasm = useCallback(async (node) => {
const { run } = await import("<path to wasm>");
run(node);
}, []);
return <div ref={getRefAndRunWasm} />;
} of course, the code changed a bit and this solution doesn't really match anymore with the example provided, so here the start of my #[wasm_bindgen]
pub fn run(cont: &HtmlElement) -> Result<(), JsValue> { |
Thank you for posting this, @Elias-Graf. What did you use for the |
@reggie3 |
@Elias-Graf Thanks for the response. I realized that I'm on Next 12 and with some work, I was able to get the following working locally, but not in build due to this existing issue that is documented here: #29362
|
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
11.0.1
What version of Node.js are you using?
15.6.0
What browser are you using?
Edge
What operating system are you using?
Windows
How are you deploying your application?
npm run dev
Describe the Bug
I may create a new webpack project that imports WebAssembly without even needing configuration. In Next.js I cannot get it to work, with, or without configuration.
Without any configuration in
next.config.js
I get:If I add the configuration described here I get:
Here the WebAssembly (rust) source code in case it is of any help:
Expected Behavior
I would expect that I could easily configure Next.js to use WebAssembly, but I cannot find any clear documentation at the moment. Preferably I wouldn't need to configure anything.
To Reproduce
First checkout the plain webpack repository:
It works without configuration (at least for me).
Now the Next.js repository:
The text was updated successfully, but these errors were encountered: