@@ -13,9 +13,9 @@ import { outdent } from 'outdent'
13
13
import { IMAGE_FUNCTION_NAME } from '../constants'
14
14
15
15
import { getRequiredServerFiles , NextConfig } from './config'
16
+ import { writeEdgeFunctionConfiguration } from './functionsMetaData'
16
17
import { makeLocaleOptional , stripLookahead , transformCaptureGroups } from './matchers'
17
18
import { RoutesManifest } from './types'
18
-
19
19
// This is the format as of [email protected]
20
20
interface EdgeFunctionDefinitionV1 {
21
21
env : string [ ]
@@ -57,12 +57,14 @@ export interface FunctionManifest {
57
57
name ?: string
58
58
path : string
59
59
cache ?: 'manual'
60
+ generator ?: string
60
61
}
61
62
| {
62
63
function : string
63
64
name ?: string
64
65
pattern : string
65
66
cache ?: 'manual'
67
+ generator ?: string
66
68
}
67
69
>
68
70
import_map ?: string
@@ -220,15 +222,17 @@ const generateEdgeFunctionMiddlewareMatchers = ({
220
222
const middlewareMatcherToEdgeFunctionDefinition = (
221
223
matcher : MiddlewareMatcher ,
222
224
name : string ,
225
+ generator : string ,
223
226
cache ?: 'manual' ,
224
227
) : {
225
228
function : string
226
229
name ?: string
227
230
pattern : string
228
231
cache ?: 'manual'
232
+ generator ?: string
229
233
} => {
230
234
const pattern = transformCaptureGroups ( stripLookahead ( matcher . regexp ) )
231
- return { function : name , pattern, name, cache }
235
+ return { function : name , pattern, name, cache, generator }
232
236
}
233
237
234
238
export const cleanupEdgeFunctions = ( {
@@ -262,7 +266,7 @@ export const writeDevEdgeFunction = async ({
262
266
* Writes an edge function that routes RSC data requests to the `.rsc` route
263
267
*/
264
268
265
- export const writeRscDataEdgeFunction = async ( {
269
+ export const writeRscDataEdgeFunction = async ( {
266
270
prerenderManifest,
267
271
appPathRoutesManifest,
268
272
} : {
@@ -343,6 +347,9 @@ export const writeEdgeFunctions = async ({
343
347
netlifyConfig : NetlifyConfig
344
348
routesManifest : RoutesManifest
345
349
} ) => {
350
+
351
+ const nextjsPluginVersion = await writeEdgeFunctionConfiguration ( )
352
+
346
353
const manifest : FunctionManifest = {
347
354
functions : [ ] ,
348
355
version : 1 ,
@@ -400,7 +407,7 @@ export const writeEdgeFunctions = async ({
400
407
} )
401
408
402
409
manifest . functions . push (
403
- ...matchers . map ( ( matcher ) => middlewareMatcherToEdgeFunctionDefinition ( matcher , functionName ) ) ,
410
+ ...matchers . map ( ( matcher ) => middlewareMatcherToEdgeFunctionDefinition ( matcher , functionName , nextjsPluginVersion ) ) ,
404
411
)
405
412
}
406
413
// Functions (i.e. not middleware, but edge SSR and API routes)
@@ -440,6 +447,7 @@ export const writeEdgeFunctions = async ({
440
447
pattern,
441
448
// cache: "manual" is currently experimental, so we restrict it to sites that use experimental appDir
442
449
cache : usesAppDir ? 'manual' : undefined ,
450
+ generator : `${ nextjsPluginVersion } ` ,
443
451
} )
444
452
// pages-dir page routes also have a data route. If there's a match, add an entry mapping that to the function too
445
453
const dataRoute = dataRoutesMap . get ( edgeFunctionDefinition . page )
@@ -449,6 +457,7 @@ export const writeEdgeFunctions = async ({
449
457
name : edgeFunctionDefinition . name ,
450
458
pattern : dataRoute ,
451
459
cache : usesAppDir ? 'manual' : undefined ,
460
+ generator : `${ nextjsPluginVersion } `
452
461
} )
453
462
}
454
463
}
@@ -474,6 +483,7 @@ export const writeEdgeFunctions = async ({
474
483
function : 'ipx' ,
475
484
name : 'next/image handler' ,
476
485
path : '/_next/image*' ,
486
+ generator : `${ nextjsPluginVersion } `
477
487
} )
478
488
} else {
479
489
console . log (
@@ -487,6 +497,6 @@ export const writeEdgeFunctions = async ({
487
497
This feature is in beta. Please share your feedback here: https://ntl.fyi/next-netlify-edge
488
498
` )
489
499
}
490
-
500
+ console . log ( 'MANIFEST' , manifest , nextjsPluginVersion )
491
501
await writeJson ( join ( edgeFunctionRoot , 'manifest.json' ) , manifest )
492
502
}
0 commit comments