[next] Add flag for experimental grouping (#11177)

Just adds a flag for experimenting
This commit is contained in:
JJ Kasper
2024-02-20 18:03:03 -08:00
committed by GitHub
parent 7910f2f307
commit ea0e9aeaec
3 changed files with 18 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@vercel/next": patch
---
[next] Add flag for experimental grouping

View File

@@ -186,6 +186,10 @@ export async function serverBuild({
}): Promise<BuildResult> {
lambdaPages = Object.assign({}, lambdaPages, lambdaAppPaths);
const experimentalAllowBundling = Boolean(
process.env.NEXT_EXPERIMENTAL_FUNCTION_BUNDLING
);
const lambdas: { [key: string]: Lambda } = {};
const prerenders: { [key: string]: Prerender } = {};
const lambdaPageKeys = Object.keys(lambdaPages);
@@ -883,6 +887,7 @@ export async function serverBuild({
const pageExtensions = requiredServerFilesManifest.config?.pageExtensions;
const pageLambdaGroups = await getPageLambdaGroups({
experimentalAllowBundling,
entryPath: projectDir,
config,
functionsConfigManifest,
@@ -904,6 +909,7 @@ export async function serverBuild({
}
const appRouterLambdaGroups = await getPageLambdaGroups({
experimentalAllowBundling,
entryPath: projectDir,
config,
functionsConfigManifest,
@@ -922,6 +928,7 @@ export async function serverBuild({
});
const appRouteHandlersLambdaGroups = await getPageLambdaGroups({
experimentalAllowBundling,
entryPath: projectDir,
config,
functionsConfigManifest,

View File

@@ -804,6 +804,7 @@ export interface CreateLambdaFromPseudoLayersOptions
layers: PseudoLayer[];
isStreaming?: boolean;
nextVersion?: string;
experimentalAllowBundling?: boolean;
}
// measured with 1, 2, 5, 10, and `os.cpus().length || 5`
@@ -815,6 +816,7 @@ export async function createLambdaFromPseudoLayers({
layers,
isStreaming,
nextVersion,
experimentalAllowBundling,
...lambdaOptions
}: CreateLambdaFromPseudoLayersOptions) {
await createLambdaSema.acquire();
@@ -862,6 +864,7 @@ export async function createLambdaFromPseudoLayers({
slug: 'nextjs',
version: nextVersion,
},
experimentalAllowBundling,
});
}
@@ -1502,6 +1505,7 @@ export async function getPageLambdaGroups({
internalPages,
pageExtensions,
inversedAppPathManifest,
experimentalAllowBundling,
}: {
entryPath: string;
config: Config;
@@ -1524,6 +1528,7 @@ export async function getPageLambdaGroups({
internalPages: string[];
pageExtensions?: string[];
inversedAppPathManifest?: Record<string, string>;
experimentalAllowBundling?: boolean;
}) {
const groups: Array<LambdaGroup> = [];
@@ -1565,6 +1570,7 @@ export async function getPageLambdaGroups({
let matchingGroup = groups.find(group => {
const matches =
!experimentalAllowBundling &&
group.maxDuration === opts.maxDuration &&
group.memory === opts.memory &&
group.isPrerenders === isPrerenderRoute &&