-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat: expose middleware URL to integrations #7458
feat: expose middleware URL to integrations #7458
Conversation
🦋 Changeset detectedLatest commit: 5462af5 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 |
8eee9e1
to
1375192
Compare
1375192
to
c62ecfa
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.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
if (chunk.type === 'asset') { | ||
continue; | ||
} | ||
if (chunk.fileName === 'middleware.mjs') { |
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 will put this string in a shared variable in the following PRs
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.
Awesome! Just left a small formatting nit
continue; | ||
} | ||
if (chunk.fileName === 'middleware.mjs') { | ||
internals.middlewareEntryPoint = new URL(chunkName, opts.settings.config.outDir); |
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.
Should we combine outDir
+ "server"
+ chunkName
here so we don't have to handle constructing the final middlewareEntryPoint
again incore/build/index.ts
? Otherwise this URL path would also point to a non existent path.
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.
Technically, at this point of the execution, the path is correct. The files are moved later. If we decided to prefix "server"
here, we would create a URL
that point to a file that doesn't exist. If, in the future, we decide to expose this information to a hook that is called before the files are moved, we could incur an error.
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.
That's fair 👍 I'm mostly concerned that the final constructed path takes a lot of work to do so, which might not be great for perf. I won't let this block the PR though, I'm also fine with this for now.
72fdbfb
to
fabe9ab
Compare
d6d7076
to
7d1395a
Compare
Looks like there's a CI fail, but the direction is good for me. |
7d1395a
to
5462af5
Compare
Changes
This is another feature towards the support of Vercel Edge Middleware.
This feature exposes the file path of the middleware file emitted during the astro build.
Testing
I extended the functionality of the test adapter and created a test that makes sure that the file exists and it has content.
Docs
I will document the new payload towards the end of the feature.