From ea4afd9df3f6e72b848ec10e9b0dd46a06bc5615 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Tue, 6 Jun 2023 14:26:49 +0200 Subject: [PATCH 1/3] refactor: use LAMBDA_WARNING_SIZE as packing threshold --- packages/runtime/src/helpers/functions.ts | 5 ++--- test/helpers/functionsMetaData.spec.ts | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/runtime/src/helpers/functions.ts b/packages/runtime/src/helpers/functions.ts index 283b86a9fc..fdf9752d91 100644 --- a/packages/runtime/src/helpers/functions.ts +++ b/packages/runtime/src/helpers/functions.ts @@ -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' @@ -314,8 +315,6 @@ const getBundleWeight = async (patterns: string[]) => { return sum(sizes.flat(1)) } -const MB = 1024 * 1024 - export const getAPILambdas = async ( publish: string, baseDir: string, @@ -323,7 +322,7 @@ export const getAPILambdas = async ( ): Promise => { 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) diff --git a/test/helpers/functionsMetaData.spec.ts b/test/helpers/functionsMetaData.spec.ts index 1835863d5f..8a259c40b9 100644 --- a/test/helpers/functionsMetaData.spec.ts +++ b/test/helpers/functionsMetaData.spec.ts @@ -4,6 +4,7 @@ import { join } from 'pathe' import { NEXT_PLUGIN_NAME } from '../../packages/runtime/src/constants' import { writeFunctionConfiguration } from '../../packages/runtime/src/helpers/functionsMetaData' +import { getFunctionNameForPage } from '../../packages/runtime/src/helpers/utils' describe('writeFunctionConfiguration', () => { afterEach(() => { @@ -103,4 +104,8 @@ describe('writeFunctionConfiguration', () => { expect(actual).toEqual(expected) }) + + it('test', () => { + expect(getFunctionNameForPage('/api/shows/[id]')).toEqual('index') + }) }) From 89e68ba29ed55042d9c78c32c354b3254e214d6a Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Tue, 6 Jun 2023 14:28:59 +0200 Subject: [PATCH 2/3] chore: remove leftover test --- test/helpers/functionsMetaData.spec.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/helpers/functionsMetaData.spec.ts b/test/helpers/functionsMetaData.spec.ts index 8a259c40b9..1dae5b703e 100644 --- a/test/helpers/functionsMetaData.spec.ts +++ b/test/helpers/functionsMetaData.spec.ts @@ -104,8 +104,4 @@ describe('writeFunctionConfiguration', () => { expect(actual).toEqual(expected) }) - - it('test', () => { - expect(getFunctionNameForPage('/api/shows/[id]')).toEqual('index') - }) }) From 4b8ba645e2521620da7029ad38b6b55eb0a23bc1 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 7 Jun 2023 09:13:29 +0200 Subject: [PATCH 3/3] Update test/helpers/functionsMetaData.spec.ts Co-authored-by: Nick Taylor --- test/helpers/functionsMetaData.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/helpers/functionsMetaData.spec.ts b/test/helpers/functionsMetaData.spec.ts index 1dae5b703e..1835863d5f 100644 --- a/test/helpers/functionsMetaData.spec.ts +++ b/test/helpers/functionsMetaData.spec.ts @@ -4,7 +4,6 @@ import { join } from 'pathe' import { NEXT_PLUGIN_NAME } from '../../packages/runtime/src/constants' import { writeFunctionConfiguration } from '../../packages/runtime/src/helpers/functionsMetaData' -import { getFunctionNameForPage } from '../../packages/runtime/src/helpers/utils' describe('writeFunctionConfiguration', () => { afterEach(() => {