Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

fix: also copy chunks for the revalidate lambda #1099

Merged
merged 1 commit into from
May 21, 2021
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
36 changes: 20 additions & 16 deletions packages/libs/lambda-at-edge/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class Builder {
* @param destination
*/
async processAndCopyRoutesManifest(source: string, destination: string) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const routesManifest = require(source) as RoutesManifest;

// Remove default trailing slash redirects as they are already handled without regex matching.
Expand Down Expand Up @@ -261,6 +262,7 @@ class Builder {
async buildDefaultLambda(
buildManifest: OriginRequestDefaultHandlerManifest
): Promise<void[]> {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const prerenderManifest = require(join(
this.dotNextDir,
"prerender-manifest.json"
Expand Down Expand Up @@ -321,14 +323,7 @@ class Builder {
}
}
),
// copy chunks if present and not using serverless trace
!this.buildOptions.useServerlessTraceTarget &&
fse.existsSync(join(this.serverlessDir, "chunks"))
? fse.copy(
join(this.serverlessDir, "chunks"),
join(this.outputDir, DEFAULT_LAMBDA_CODE_DIR, "chunks")
)
: Promise.resolve(),
this.copyChunks(DEFAULT_LAMBDA_CODE_DIR),
fse.copy(
join(this.dotNextDir, "prerender-manifest.json"),
join(this.outputDir, DEFAULT_LAMBDA_CODE_DIR, "prerender-manifest.json")
Expand Down Expand Up @@ -388,14 +383,7 @@ class Builder {
join(this.serverlessDir, "pages/api"),
join(this.outputDir, API_LAMBDA_CODE_DIR, "pages/api")
),
// copy chunks if present and not using serverless trace
!this.buildOptions.useServerlessTraceTarget &&
fse.existsSync(join(this.serverlessDir, "chunks"))
? fse.copy(
join(this.serverlessDir, "chunks"),
join(this.outputDir, API_LAMBDA_CODE_DIR, "chunks")
)
: Promise.resolve(),
this.copyChunks(API_LAMBDA_CODE_DIR),
fse.writeJson(
join(this.outputDir, API_LAMBDA_CODE_DIR, "manifest.json"),
apiBuildManifest
Expand All @@ -421,6 +409,7 @@ class Builder {
join(this.outputDir, REGENERATION_LAMBDA_CODE_DIR),
!!this.buildOptions.minifyHandlers
),
this.copyChunks(REGENERATION_LAMBDA_CODE_DIR),
fse.copy(
join(this.serverlessDir, "pages"),
join(this.outputDir, REGENERATION_LAMBDA_CODE_DIR, "pages"),
Expand All @@ -441,6 +430,19 @@ class Builder {
]);
}

/**
* copy chunks if present and not using serverless trace
*/
async copyChunks(buildDir: string): Promise<void> {
return !this.buildOptions.useServerlessTraceTarget &&
fse.existsSync(join(this.serverlessDir, "chunks"))
? fse.copy(
join(this.serverlessDir, "chunks"),
join(this.outputDir, buildDir, "chunks")
)
: Promise.resolve();
}

/**
* Build image optimization lambda (supported by Next.js 10)
* @param buildManifest
Expand Down Expand Up @@ -793,11 +795,13 @@ class Builder {
await restoreUserConfig();
}

// eslint-disable-next-line @typescript-eslint/no-var-requires
const routesManifest = require(join(
this.dotNextDir,
"routes-manifest.json"
));

// eslint-disable-next-line @typescript-eslint/no-var-requires
const prerenderManifest = require(join(
this.dotNextDir,
"prerender-manifest.json"
Expand Down