@@ -9,6 +9,8 @@ import { OutputBundleOptions, RoutesManifest } from "./interfaces.js";
99import { NextConfigComplete } from "next/dist/server/config-shared.js" ;
1010import { OutputBundleConfig } from "@apphosting/common" ;
1111import { AdapterMetadata } from "./interfaces.js" ;
12+ import { MiddlewareManifest } from "next/dist/build/webpack/plugins/middleware-plugin.js" ;
13+ import { MIDDLEWARE_MANIFEST } from "next/constants.js" ;
1214
1315// fs-extra is CJS, readJson can't be imported using shorthand
1416export const { move, exists, writeFile, readJson, readdir, readFileSync, existsSync, mkdir } =
@@ -43,6 +45,15 @@ export async function loadRouteManifest(
4345 return JSON . parse ( json ) as RoutesManifest ;
4446}
4547
48+ export async function loadMiddlewareManifest (
49+ standalonePath : string ,
50+ distDir : string ,
51+ ) : Promise < MiddlewareManifest > {
52+ const manifestPath = join ( standalonePath , distDir , MIDDLEWARE_MANIFEST ) ;
53+ const json = readFileSync ( manifestPath , "utf-8" ) ;
54+ return JSON . parse ( json ) as MiddlewareManifest ;
55+ }
56+
4657export async function writeRouteManifest (
4758 standalonePath : string ,
4859 distDir : string ,
@@ -52,11 +63,6 @@ export async function writeRouteManifest(
5263 await writeFile ( manifestPath , JSON . stringify ( customManifest ) ) ;
5364}
5465
55- export function middlewareExists ( standalonePathDir : string , distdir : string ) : boolean {
56- const middlwarePath = join ( standalonePathDir , distdir , "server/middleware.js" ) ;
57- return existsSync ( middlwarePath ) ;
58- }
59-
6066export const isMain = ( meta : ImportMeta ) : boolean => {
6167 if ( ! meta ) return false ;
6268 if ( ! process . argv [ 1 ] ) return false ;
0 commit comments