@@ -56,6 +56,19 @@ const augmentMatchers = (
56
56
const getHandlerName = ( { name } : Pick < NextDefinition , 'name' > ) : string =>
57
57
`${ EDGE_HANDLER_NAME } -${ name . replace ( / \W / g, '-' ) } `
58
58
59
+ const getEdgeFunctionSharedConfig = (
60
+ ctx : PluginContext ,
61
+ { name, page } : Pick < NextDefinition , 'name' | 'page' > ,
62
+ ) => {
63
+ return {
64
+ name : name . endsWith ( 'middleware' )
65
+ ? 'Next.js Middleware Handler'
66
+ : `Next.js Edge Handler: ${ page } ` ,
67
+ cache : name . endsWith ( 'middleware' ) ? undefined : ( 'manual' as const ) ,
68
+ generator : `${ ctx . pluginName } @${ ctx . pluginVersion } ` ,
69
+ }
70
+ }
71
+
59
72
const writeHandlerFile = async ( ctx : PluginContext , { matchers, name, page } : NextDefinition ) => {
60
73
const nextConfig = ctx . buildConfig
61
74
const handlerName = getHandlerName ( { name } )
@@ -87,16 +100,13 @@ const writeHandlerFile = async (ctx: PluginContext, { matchers, name, page }: Ne
87
100
JSON . stringify ( minimalNextConfig ) ,
88
101
)
89
102
90
- const isc = ctx . useFrameworksAPI
91
- ? `export const config = ${ JSON . stringify ( {
92
- name : name . endsWith ( 'middleware' )
93
- ? 'Next.js Middleware Handler'
94
- : `Next.js Edge Handler: ${ page } ` ,
95
- pattern : augmentedMatchers . map ( ( matcher ) => matcher . regexp ) ,
96
- cache : name . endsWith ( 'middleware' ) ? undefined : 'manual' ,
97
- generator : `${ ctx . pluginName } @${ ctx . pluginVersion } ` ,
98
- } satisfies IntegrationsConfig ) } ;`
99
- : ``
103
+ const isc =
104
+ ctx . edgeFunctionsConfigStrategy === 'inline'
105
+ ? `export const config = ${ JSON . stringify ( {
106
+ ...getEdgeFunctionSharedConfig ( ctx , { name, page } ) ,
107
+ pattern : augmentedMatchers . map ( ( matcher ) => matcher . regexp ) ,
108
+ } satisfies IntegrationsConfig ) } ;`
109
+ : ``
100
110
101
111
// Writing the function entry file. It wraps the middleware code with the
102
112
// compatibility layer mentioned above.
@@ -157,18 +167,11 @@ const buildHandlerDefinition = (
157
167
{ name, matchers, page } : NextDefinition ,
158
168
) : Array < ManifestFunction > => {
159
169
const fun = getHandlerName ( { name } )
160
- const funName = name . endsWith ( 'middleware' )
161
- ? 'Next.js Middleware Handler'
162
- : `Next.js Edge Handler: ${ page } `
163
- const cache = name . endsWith ( 'middleware' ) ? undefined : ( 'manual' as const )
164
- const generator = `${ ctx . pluginName } @${ ctx . pluginVersion } `
165
170
166
171
return augmentMatchers ( matchers , ctx ) . map ( ( matcher ) => ( {
172
+ ...getEdgeFunctionSharedConfig ( ctx , { name, page } ) ,
167
173
function : fun ,
168
- name : funName ,
169
174
pattern : matcher . regexp ,
170
- cache,
171
- generator,
172
175
} ) )
173
176
}
174
177
@@ -184,7 +187,7 @@ export const createEdgeHandlers = async (ctx: PluginContext) => {
184
187
]
185
188
await Promise . all ( nextDefinitions . map ( ( def ) => createEdgeHandler ( ctx , def ) ) )
186
189
187
- if ( ! ctx . useFrameworksAPI ) {
190
+ if ( ctx . edgeFunctionsConfigStrategy === 'manifest' ) {
188
191
const netlifyDefinitions = nextDefinitions . flatMap ( ( def ) => buildHandlerDefinition ( ctx , def ) )
189
192
const netlifyManifest : Manifest = {
190
193
version : 1 ,
0 commit comments