-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
Cannot load wasm files; compiling stucks at 98% #5277
Comments
Found out that the However, the import will now return a 404 code as well. GET http://localhost:3000/_next/24c3009c365c8fdcc4bd.module.wasm 404 (Not Found) Even though the file exists in The file inside |
The next versions of Looking through the sources of next.js I found this: // server/index.js
routes['/_next/:path*'] = async (req, res, params, parsedUrl) => {
await this.render404(req, res, parsedUrl)
} So, every request to This is a workaround, but I guess there is a better solution: routes['/_next/:path*'] = async (req, res, params, parsedUrl) => {
if (/\.wasm$/.test(parsedUrl.pathname)) {
const p = join(this.distDir, ...(params.path || []))
res.setHeader('Content-Type', 'application/wasm')
await this.serveStatic(req, res, p)
return
}
await this.render404(req, res, parsedUrl)
} Maybe something in the webpack config or an extra case for the server? |
As you can see here the route should be served: https://github.com/zeit/next.js/blob/canary/server/index.js#L127-L141 But, it doesn't serve it with that specific mime type for wasm, as the mime-types in the |
But this path only applies only for Not in
|
Check this example https://github.com/zeit/next.js/tree/canary/examples/with-webassembly |
Ahh, I see. Wouldn't it make more sense to add it as a default? PS: I'v actually searched for an example but just cmd+f -> wasm and totally skipped the webassembly one 😅. |
We might rename |
I think it makes sense to add the |
Actually we probably should add this as per the issue:
And then add the |
Bug report
Describe the bug
I tried to load a wasm module with a dynamic import.
The module was created with
wasm-bindgen
and works when used with webpack alone.Here is the wasm-bindgen example
To Reproduce
The included zipfile contains the precompiled wasm file from the wasm-bindgen example.
It should be enough to run
npm i
,npm run dev
and then openlocalhost:3000
in the browser.next-wasm.zip
Expected behavior
The wasm module should be loaded dynamically and return an object with the function
greet
.Error
Here is the terminal output.
It will just stay at 98%.
The error message came only after waiting for some minutes and then hitting Ctrl+C,
if you don't wait and just hit Ctrl+C it, it won't show anything.
System information
Additional context
Building and exporting seem to work, however, if it tries to load the wasm file it will return a 404 response.
The text was updated successfully, but these errors were encountered: