-
Notifications
You must be signed in to change notification settings - Fork 93
chore: update edge functions implementation #1380
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-export-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 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-demo 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 netlify-plugin-nextjs-next-auth-demo 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 next-i18next-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
❌ Deploy Preview for next-plugin-canary failed.
|
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
✅ Deploy Preview for next-plugin-canary ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
55e0ab4
to
518baad
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.
LGTM!
@@ -30,45 +32,42 @@ const loadMiddlewareManifest = (netlifyConfig: NetlifyConfig): Promise<Middlewar | |||
/** | |||
* Convert the Next middleware name into a valid Edge Function name | |||
*/ | |||
const sanitizeName = (name: string) => `next${name === '/' ? '_index' : name.replace(/\W/g, '_')}` | |||
const sanitizeName = (name: string) => `next_${name.replace(/\W/g, '_')}` |
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.
I imagine it's a change in Next.js, but I guess the name is never /
anymore, hence the change?
globalThis._ENTRIES ||= {} | ||
// Deno defines "window", but naughty libraries think this means it's a browser |
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.
Anecdotal, but it seems odd they define the window
object for something that never runs in the browser, or is this maybe for some stuff related to WASM?
await copyEdgeSourceFile({ edgeFunctionDir, file: 'utils.ts' }) | ||
return { | ||
function: name, | ||
pattern: stripLookahead(edgeFunctionDefinition.regexp), |
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.
Since we strip the lookahead, does this mean that there are some things we cannot support with this Edge function?
Summary
As Next middleware gets closer to GA, they've made some more changes to the internal implementation. This PR handles changes to the way edge functions and middleware are defined in the manifest. Edge functions (and server components) are no longer included in
sortedMiddleware
, but are instead in thefunctions
object. We now loop through sorted middleware (which in future will only have a maximum of one entry) as this allows for backward-compatiblity. We then include every entry infunctions
.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.