Skip to content

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

Merged
merged 9 commits into from
Jun 22, 2022
Merged

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Jun 10, 2022

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 the functions 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 in functions.

Test plan

  1. Visit the middleware and server-components deploy previews and ensure they work

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

capybara with magpie on its head

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was published correctly.

@netlify
Copy link

netlify bot commented Jun 10, 2022

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit c804e10
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/62b2f2a6fc6bce00080aeb92
😎 Deploy Preview https://deploy-preview-1380--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Jun 10, 2022

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit c804e10
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/62b2f2a6dfc0810008f8658b
😎 Deploy Preview https://deploy-preview-1380--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Jun 10, 2022

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit c804e10
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/62b2f2a6d93ee5000936471f
😎 Deploy Preview https://deploy-preview-1380--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Jun 10, 2022

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit c804e10
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/62b2f2a6a0822c0009047de3
😎 Deploy Preview https://deploy-preview-1380--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added the type: chore work needed to keep the product and development running smoothly label Jun 10, 2022
@netlify
Copy link

netlify bot commented Jun 10, 2022

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit c804e10
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/62b2f2a6b24486000818e617
😎 Deploy Preview https://deploy-preview-1380--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Jun 10, 2022

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit c804e10
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/62b2f2a6a0822c0009047de8
😎 Deploy Preview https://deploy-preview-1380--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Jun 10, 2022

Deploy Preview for next-plugin-rsc-demo ready!

Name Link
🔨 Latest commit c804e10
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-rsc-demo/deploys/62b2f2a6dfc0810008f86590
😎 Deploy Preview https://deploy-preview-1380--next-plugin-rsc-demo.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Jun 10, 2022

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit c804e10
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/62b2f2a6d93ee50009364724
😎 Deploy Preview https://deploy-preview-1380--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Jun 10, 2022

Deploy Preview for next-plugin-canary failed.

Name Link
🔨 Latest commit 9fa83fa
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/62a35d0a07db84000828e3d1

@cypress
Copy link

cypress bot commented Jun 10, 2022



Test summary

7 0 0 0


Run details

Project netlify-plugin-nextjs-static-demo
Status Passed
Commit f942c74 ℹ️
Started Jun 22, 2022 10:48 AM
Ended Jun 22, 2022 10:49 AM
Duration 01:18 💡
OS Linux Ubuntu - 20.04
Browser Chrome 102

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

@cypress
Copy link

cypress bot commented Jun 10, 2022



Test summary

21 0 0 0


Run details

Project netlify-plugin-nextjs-default-demo
Status Passed
Commit f942c74 ℹ️
Started Jun 22, 2022 10:48 AM
Ended Jun 22, 2022 10:49 AM
Duration 01:29 💡
OS Linux Ubuntu - 20.04
Browser Chrome 102

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

@cypress
Copy link

cypress bot commented Jun 10, 2022



Test summary

2 0 0 0


Run details

Project netlify-plugin-nextjs-nx-monorepo-demo
Status Passed
Commit f942c74 ℹ️
Started Jun 22, 2022 10:48 AM
Ended Jun 22, 2022 10:50 AM
Duration 01:12 💡
OS Linux Ubuntu - 20.04
Browser Chrome 102

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

@netlify
Copy link

netlify bot commented Jun 22, 2022

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit c804e10
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/62b2f2a60e326c0008e42cbc
😎 Deploy Preview https://deploy-preview-1380--next-plugin-canary.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@ascorbic ascorbic changed the title chore: update edge function demos chore: update edge functions implementation Jun 22, 2022
@ascorbic ascorbic force-pushed the mk/edge-example-updates branch from 55e0ab4 to 518baad Compare June 22, 2022 10:24
@ascorbic ascorbic marked this pull request as ready for review June 22, 2022 10:54
@ascorbic ascorbic requested a review from a team June 22, 2022 10:54
@ascorbic ascorbic self-assigned this Jun 22, 2022
Copy link

@sarahetter sarahetter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kodiakhq kodiakhq bot merged commit d09a298 into main Jun 22, 2022
@kodiakhq kodiakhq bot deleted the mk/edge-example-updates branch June 22, 2022 13:41
@@ -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, '_')}`

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

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),

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: chore work needed to keep the product and development running smoothly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants