Skip to content

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 26 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
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 Oct 11, 2022
95a4c3d
chore: snapidoo
ascorbic Oct 11, 2022
bff9b41
chore: log
ascorbic Oct 11, 2022
4f441a7
chore: log fetch wrapper
ascorbic Oct 11, 2022
25d1078
fix: allow acess to edge-chunks
ascorbic Oct 11, 2022
6066566
chore: make example more dynamic
ascorbic Oct 11, 2022
ca45977
chore: add image debug, remove logs
ascorbic Oct 11, 2022
04b61fa
chore: remove debug
ascorbic Oct 11, 2022
322c752
fix: inlline assets
ascorbic Oct 11, 2022
91b05a5
chore: nicer example
ascorbic Oct 12, 2022
8a3156a
chore: error handling
ascorbic Oct 12, 2022
3275dbb
chore: remove log and format
ascorbic Oct 12, 2022
3258cc0
chore: add e2e test
ascorbic Oct 14, 2022
f5cd786
Merge branch 'main' into mk/wasm-support
ascorbic Oct 14, 2022
0e498e8
Merge branch 'main' into mk/wasm-support
ascorbic Oct 15, 2022
0024db9
Merge branch 'main' into mk/wasm-support
ascorbic Oct 17, 2022
983444d
chore: fix test
ascorbic Oct 17, 2022
348abe0
chore: re-enable dev check in edge function
ascorbic Oct 17, 2022
c73b564
chore: change from review
ascorbic Oct 17, 2022
3957c99
Merge branch 'main' into mk/wasm-support
nickytonline Oct 17, 2022
b608a05
Merge branch 'main' into mk/wasm-support
ascorbic Oct 18, 2022
6cb97a8
chore: update snapshots
ascorbic Oct 18, 2022
4688e57
Merge branch 'main' into mk/wasm-support
ascorbic Oct 18, 2022
3563bb8
Merge branch 'main' into mk/wasm-support
ascorbic Oct 19, 2022
f847729
Merge branch 'main' into mk/wasm-support
ascorbic Oct 24, 2022
4144135
fix: correct content-length in middleware
ascorbic Oct 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cypress/integration/default/wasm.spec.ts
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)
})
})
})
6 changes: 3 additions & 3 deletions demos/default/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ module.exports = {
remotePatterns: [
{
hostname: '*.imgur.com',
}
]
},
],
},
// https://nextjs.org/docs/basic-features/built-in-css-support#customizing-sass-options
sassOptions: {
includePaths: [path.join(__dirname, 'styles-sass-test')],
},
experimental: {
optimizeCss: false,
}
},
}
1 change: 1 addition & 0 deletions demos/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dependencies": {
"@reach/dialog": "^0.16.2",
"@reach/visually-hidden": "^0.16.0",
"@vercel/og": "^0.0.15",
"next": "^12.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
Expand Down
48 changes: 48 additions & 0 deletions demos/default/pages/api/og.tsx
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(

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

(
<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 &quot;?username=netlify&quot;</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',
},
},
)
}
Loading