-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: update edgeMiddleware references to middlewareMode
#13277
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
base: v6
Are you sure you want to change the base?
Changes from 8 commits
f4015c0
067d75a
7100101
d54d409
10c8f7f
eca6d5c
3914827
7a3197e
681defb
c366be7
2145651
a509d9d
cb4f812
6526628
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1041,16 +1041,20 @@ Defines whether the adapter supports image transformation using the built-in Sha | |
|
|
||
| A set of features that changes the output of the emitted files. When an adapter opts in to these features, they will get additional information inside specific hooks and must implement the proper logic to handle the different output. | ||
|
|
||
| ### `edgeMiddleware` | ||
| ### `middlewareMode` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noting that this is causing a link failure in Would be great if @jp-knj or @morinokami could jump in here! We can translate just the heading, then use that as the anchor link on the Netlify page (but still mark this as [i18nIgnore] so that it's clear the pages do still need the regular updates. One thing we could do that doesn't have to include any translations yet, since the Netlify guide will need to update anyway is that this PR could temporarily just update the |
||
|
|
||
| <p> | ||
|
|
||
| **Type:** `boolean` | ||
| **Type:** [`MiddlewareMode`](#middlewaremode-1)<br /> | ||
| **Default:** `"classic"`<br /> | ||
| <Since v="6.0.0" /> | ||
| </p> | ||
|
|
||
| Defines whether any on-demand rendering middleware code will be bundled when built. | ||
| Determines at which stage of the page lifecycle the middleware is executed, and how the middleware code is emitted in the build output. | ||
|
|
||
| The `classic` mode matches the default behavior of Astro. On prerendered pages, middleware is run at build time, and when the page is requested, the middleware is not run again. On dynamic pages, middleware is run at request time only. The middleware code is part of your server bundle. | ||
|
|
||
| When enabled, this prevents middleware code from being bundled and imported by all pages during the build: | ||
| In `edge` mode, the middleware code can be deployed independently from the server bundle, for example, as an edge function. | ||
|
|
||
| ```js title="my-adapter.mjs" ins={10-12} | ||
| export default function createIntegration() { | ||
|
|
@@ -1063,7 +1067,7 @@ export default function createIntegration() { | |
| entrypointResolution: 'auto', | ||
ArmandPhilippot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| serverEntrypoint: '@example/my-adapter/server.js', | ||
| adapterFeatures: { | ||
| edgeMiddleware: true | ||
| middlewareMode: 'edge' | ||
| } | ||
| }); | ||
| }, | ||
|
|
@@ -1085,7 +1089,7 @@ export default function createIntegration() { | |
| entrypointResolution: 'auto', | ||
leekeh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| serverEntrypoint: '@example/my-adapter/server.js', | ||
| adapterFeatures: { | ||
| edgeMiddleware: true | ||
| middlewareMode: 'edge' | ||
| } | ||
| }); | ||
| }, | ||
|
|
@@ -1287,6 +1291,16 @@ export default function createIntegration() { | |
| } | ||
| ``` | ||
|
|
||
| ### `MiddlewareMode` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ArmandPhilippot I'll ask for your guidance here. Somehow it feels less helpful to have such a short entry here that actually tells people which values they can set as a middleware mode? I would think that that it's more valuable that in the entry above for the config option, people can very quickly see "oh, it's classic or edge!" rather than see "Oh, middleware mode is a middleware mode" then need to follow a trail to get here? But, what do you think?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My take would be: Is this type useful so that the user can use it elsewhere (for example, a helper function) or is it only useful in this specific case? I would say the second one here, but I'm not an adapter builder so I could be wrong. If there are use cases for the type, while I agree with Sarah, I think this can helpful to have an entry for it (so people know they can import it). Otherwise, yes, we probably don't need this and we can replace
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use case would mainly be for adapter developers, to expose this as a property on the adapter. I'd recommend using the type over hardcoding it, since it is going to change in the (near) future. |
||
|
|
||
| <p> | ||
|
|
||
| **Type:** `"classic" | "edge"`<br /> | ||
| <Since v="6.0.0" /> | ||
leekeh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </p> | ||
|
|
||
| A union of valid formats to describe the mode in which middleware is run. | ||
|
|
||
| ## Allow installation via `astro add` | ||
|
|
||
| [The `astro add` command](/en/reference/cli-reference/#astro-add) allows users to easily add integrations and adapters to their project. To allow your adapter to be installed with this command, **add `astro-adapter` to the `keywords` field in your `package.json`**: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.