Skip to content

refactor: use LAMBDA_WARNING_SIZE as packing threshold #2156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/runtime/src/helpers/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
HANDLER_FUNCTION_TITLE,
ODB_FUNCTION_TITLE,
IMAGE_FUNCTION_TITLE,
LAMBDA_WARNING_SIZE,
} from '../constants'
import { getApiHandler } from '../templates/getApiHandler'
import { getHandler } from '../templates/getHandler'
Expand Down Expand Up @@ -314,16 +315,14 @@ const getBundleWeight = async (patterns: string[]) => {
return sum(sizes.flat(1))
}

const MB = 1024 * 1024

export const getAPILambdas = async (
publish: string,
baseDir: string,
pageExtensions: string[],
): Promise<APILambda[]> => {
const commonDependencies = await getAPIPRouteCommonDependencies(publish)

const threshold = 50 * MB - (await getBundleWeight(commonDependencies))
const threshold = LAMBDA_WARNING_SIZE - (await getBundleWeight(commonDependencies))

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

Expand Down