Skip to content

Commit 5f5199c

Browse files
committed
Merge branch 'main' into split-api-routes-displayname
2 parents 37a6e3a + eb30624 commit 5f5199c

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

packages/runtime/src/helpers/files.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,19 @@ const baseServerReplacements: Array<[string, string]> = [
404404
const nextServerReplacements: Array<[string, string]> = [
405405
[
406406
`getMiddlewareManifest() {\n if (this.minimalMode) return null;`,
407-
`getMiddlewareManifest() {\n if (this.minimalMode || (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return null;`,
407+
`getMiddlewareManifest() {\n if (this.minimalMode || (process.env.NETLIFY && process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return null;`,
408408
],
409409
[
410410
`generateCatchAllMiddlewareRoute(devReady) {\n if (this.minimalMode) return []`,
411-
`generateCatchAllMiddlewareRoute(devReady) {\n if (this.minimalMode || (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return [];`,
411+
`generateCatchAllMiddlewareRoute(devReady) {\n if (this.minimalMode || (process.env.NETLIFY && process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return [];`,
412412
],
413413
[
414414
`generateCatchAllMiddlewareRoute() {\n if (this.minimalMode) return undefined;`,
415-
`generateCatchAllMiddlewareRoute() {\n if (this.minimalMode || (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return undefined;`,
415+
`generateCatchAllMiddlewareRoute() {\n if (this.minimalMode || (process.env.NETLIFY && process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return undefined;`,
416416
],
417417
[
418418
`getMiddlewareManifest() {\n if (this.minimalMode) {`,
419-
`getMiddlewareManifest() {\n if (!this.minimalMode && (process.env.NEXT_DISABLE_NETLIFY_EDGE === 'true' || process.env.NEXT_DISABLE_NETLIFY_EDGE === '1')) {`,
419+
`getMiddlewareManifest() {\n if (!this.minimalMode && (process.env.NETLIFY && process.env.NEXT_DISABLE_NETLIFY_EDGE === 'true' || process.env.NEXT_DISABLE_NETLIFY_EDGE === '1')) {`,
420420
],
421421
]
422422

packages/runtime/src/helpers/functions.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
IMAGE_FUNCTION_TITLE,
1919
API_FUNCTION_TITLE,
2020
API_FUNCTION_NAME,
21+
LAMBDA_WARNING_SIZE,
2122
} from '../constants'
2223
import { getApiHandler } from '../templates/getApiHandler'
2324
import { getHandler } from '../templates/getHandler'
@@ -320,16 +321,14 @@ const getBundleWeight = async (patterns: string[]) => {
320321
return sum(sizes.flat(1))
321322
}
322323

323-
const MB = 1024 * 1024
324-
325324
export const getAPILambdas = async (
326325
publish: string,
327326
baseDir: string,
328327
pageExtensions: string[],
329328
): Promise<APILambda[]> => {
330329
const commonDependencies = await getAPIPRouteCommonDependencies(publish)
331330

332-
const threshold = 50 * MB - (await getBundleWeight(commonDependencies))
331+
const threshold = LAMBDA_WARNING_SIZE - (await getBundleWeight(commonDependencies))
333332

334333
const apiRoutes = await getApiRouteConfigs(publish, baseDir, pageExtensions)
335334

0 commit comments

Comments
 (0)