-
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
Merged
Merged
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
573cf24
feat: add wasm support
ascorbic 95a4c3d
chore: snapidoo
ascorbic bff9b41
chore: log
ascorbic 4f441a7
chore: log fetch wrapper
ascorbic 25d1078
fix: allow acess to edge-chunks
ascorbic 6066566
chore: make example more dynamic
ascorbic ca45977
chore: add image debug, remove logs
ascorbic 04b61fa
chore: remove debug
ascorbic 322c752
fix: inlline assets
ascorbic 91b05a5
chore: nicer example
ascorbic 8a3156a
chore: error handling
ascorbic 3275dbb
chore: remove log and format
ascorbic 3258cc0
chore: add e2e test
ascorbic f5cd786
Merge branch 'main' into mk/wasm-support
ascorbic 0e498e8
Merge branch 'main' into mk/wasm-support
ascorbic 0024db9
Merge branch 'main' into mk/wasm-support
ascorbic 983444d
chore: fix test
ascorbic 348abe0
chore: re-enable dev check in edge function
ascorbic c73b564
chore: change from review
ascorbic 3957c99
Merge branch 'main' into mk/wasm-support
nickytonline b608a05
Merge branch 'main' into mk/wasm-support
ascorbic 6cb97a8
chore: update snapshots
ascorbic 4688e57
Merge branch 'main' into mk/wasm-support
ascorbic 3563bb8
Merge branch 'main' into mk/wasm-support
ascorbic f847729
Merge branch 'main' into mk/wasm-support
ascorbic 4144135
fix: correct content-length in middleware
ascorbic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
describe('WebAssembly support', () => { | ||
it('generates an API route with wasm chunks', () => { | ||
cy.request('/api/og?username=netlify').then((response) => { | ||
// Failure state is zero-length body | ||
expect(response.body).to.have.length.above(10000) | ||
}) | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ImageResponse } from '@vercel/og' | ||
import { NextRequest } from 'next/server' | ||
|
||
export const config = { | ||
runtime: 'experimental-edge', | ||
} | ||
|
||
export default async function handler(req: NextRequest) { | ||
const { searchParams } = req.nextUrl | ||
const username = searchParams.get('username') | ||
|
||
return new ImageResponse( | ||
( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
fontSize: 60, | ||
color: 'black', | ||
background: '#f6f6f6', | ||
width: '100%', | ||
height: '100%', | ||
paddingTop: 50, | ||
flexDirection: 'column', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<img | ||
width="256" | ||
height="256" | ||
src={`https://github.com/${username || 'netlify'}.png`} | ||
style={{ | ||
borderRadius: 128, | ||
}} | ||
/> | ||
{username ? <p>github.com/{username}</p> : <p>Visit with "?username=netlify"</p>} | ||
</div> | ||
), | ||
{ | ||
width: 1200, | ||
height: 630, | ||
headers: { | ||
// By default this has an immutable cache, but this is for testing | ||
'Cache-Control': 'public, max-age=0, must-revalidate', | ||
}, | ||
}, | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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