feat: bundle the Vercel Edge Middleware function#7492
feat: bundle the Vercel Edge Middleware function#7492ematipico merged 9 commits intofeat/vercel-edge-middlewarefrom
Conversation
🦋 Changeset detectedLatest commit: 3ec8bb0 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
24ccaa7 to
06afd39
Compare
|
!preview vercel-edge-middleware |
|
|
!preview vercel-edge-middleware |
|
|
I just tried the preview release in a pet project. I tracked a minor bug, which I fixed in the last commit. After the fix, I could see the bundled The code contains the business logic of the astro middleware, plus some imported code because |
dd8e2f3 to
0c8b15b
Compare
0c8b15b to
a89db6e
Compare
cf2882d to
3ec8bb0
Compare
|
I am going to merge it. The test fail is not related to my changes. Feel free to leave more feedback and I will address it in the next PR. |
Changes
This PR adds logic to create the real Vercel Edge Middleware file. Check the documentation.
The content of the function will be something like this (this is pseudo code, but almost like the real deal):
The first
importis the Astro Middleware.The second
importis something we don't have yet, but we will be required to callonRequest. As you can see, thenextfunction is where we pass thelocals, serialize them and contact the "origin server" (the actual lambda that renders the page).As for now, locals are not part of this PR. The only goal is the creation of the
middeware.jsfile, bundled viaesbuild.Talking with @matthewp , we moved
middlewareEntryPointfromastro:build:donetoastro:build:ssr. We agreed that this information belongs to SSR, likeentryPoints.Testing
I created a test case to check if the file emitted exists.
I also manually tested using a pet project.
Docs
Still early