11import { cp , mkdir , readFile , writeFile } from 'node:fs/promises'
22import { dirname , join , parse } from 'node:path'
3- import { fileURLToPath } from 'node:url'
43
54import { glob } from 'fast-glob'
65import { pathToRegexp } from 'path-to-regexp'
76
7+ import { GENERATOR , PLUGIN_DIR } from './constants.js'
88import type { FrameworksAPIConfig , NextConfigComplete , OnBuildCompleteContext } from './types.js'
99
1010const NETLIFY_FRAMEWORKS_API_EDGE_FUNCTIONS = '.netlify/v1/edge-functions'
@@ -15,9 +15,6 @@ const MIDDLEWARE_FUNCTION_DIR = join(
1515 MIDDLEWARE_FUNCTION_NAME ,
1616)
1717
18- const MODULE_DIR = fileURLToPath ( new URL ( '.' , import . meta. url ) )
19- const PLUGIN_DIR = join ( MODULE_DIR , '../..' )
20-
2118export async function onBuildComplete (
2219 ctx : OnBuildCompleteContext ,
2320 frameworksAPIConfigArg : FrameworksAPIConfig ,
@@ -138,8 +135,10 @@ const writeHandlerFile = async (
138135 export default (req, context) => handleMiddleware(req, context, handler);
139136
140137 export const config = ${ JSON . stringify ( {
141- pattern : augmentMatchers ( middleware , nextConfig ) . map ( ( matcher ) => matcher . regexp ) ,
142138 cache : undefined ,
139+ generator : GENERATOR ,
140+ name : 'Next.js Middleware Handler' ,
141+ pattern : augmentMatchers ( middleware , nextConfig ) . map ( ( matcher ) => matcher . regexp ) ,
143142 } ) }
144143 ` ,
145144 )
0 commit comments