-
Notifications
You must be signed in to change notification settings - Fork 86
feat: add support for WebAssembly in edge runtime #1676
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
Conversation
✅ Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-i18next-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-export-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for nextjs-plugin-custom-routes-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-canary ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-edge-middleware ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-rsc-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// We need to pretend there's no edge API routes, because otherwise it'll fail | ||
// when we try to disable edge runtime. | ||
const manifest = path.join('.next', 'server', 'middleware-manifest.json') | ||
const manifestContent = await readJson(manifest) | ||
manifestContent.functions = {} | ||
await writeJSON(manifest, manifestContent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't block the PR, but could we not have a separate test for the scenario when NEXT_DISABLE_NETLIFY_EDGE=1
and we have routes, that we expect it to throw? Or maybe I'm misunderstanding the error being explained here.
const { searchParams } = req.nextUrl | ||
const username = searchParams.get('username') | ||
|
||
return new ImageResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context where this component is coming from, see the Vercel example, https://vercel.com/docs/concepts/functions/edge-functions/og-image-generation#getting-started
85ca8f5
to
22da599
Compare
22da599
to
6cb97a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @ascorbic!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Summary
Adds support for wasm in the edge runtime. When Next.js builds a site that uses wasm in the edge runtime, it emits the wasm files into the
.next/server/edge-chunks
directory. The runtime expects these chunks to be available as arraybuffers as variables, named according to the chunk name. We do this by inlining them as base64-encoded strings, then wrapping those indecode()
calls (using the Deno base64 lib).Similarly, static assets such as fonts are replaced with
blob:
URLs, which use the chunk name for the path. We handle this in the same way as the Next edge runtime: by wrappingfetch
and intercepting any calls that request a blob URI, returning the base64-encoded file in a Response instead.This PR also adds the OG image lib to the default demo, and uses it for an e2e test.
Test plan
Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal
Standard checks:
🧪 Once merged, make sure to update the version if needed and that it was published correctly.