Skip to content

Commit 35209d0

Browse files
committed
fix: copying excess files to output directory
1 parent 297e147 commit 35209d0

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.changeset/sixty-years-cheat.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
fix: copying excess files to output directory
6+
7+
In previous version, we copied the entire `.next` directory to the `.worker-next` output directory. Going forward, it will only copy the `.next/standalone` directory to this location.

packages/cloudflare/src/cli/build/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import type { ProjectOptions } from "../config";
66
import { containsDotNextDir, getConfig } from "../config";
77
import { buildNextjsApp } from "./build-next-app";
88
import { buildWorker } from "./build-worker";
9+
<<<<<<< HEAD
10+
=======
11+
import { containsDotNextDir } from "../config";
12+
import { cpSync } from "node:fs";
13+
import { rm } from "node:fs/promises";
14+
>>>>>>> 4aeb70e (fix: copying excess files to output directory)
915

1016
/**
1117
* Builds the application in a format that can be passed to workerd
@@ -27,8 +33,8 @@ export async function build(projectOpts: ProjectOptions): Promise<void> {
2733
// Clean the output directory
2834
await cleanDirectory(projectOpts.outputDir);
2935

30-
// Copy the .next directory to the output directory so it can be mutated.
31-
cpSync(join(projectOpts.sourceDir, ".next"), join(projectOpts.outputDir, ".next"), { recursive: true });
36+
// Copy the .next/standalone directory to the output directory so it can be mutated.
37+
cpSync(join(projectOpts.sourceDir, ".next", "standalone"), join(projectOpts.outputDir, ".next", "standalone"), { recursive: true });
3238

3339
const config = getConfig(projectOpts);
3440

packages/cloudflare/src/cli/config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ export type Config = {
2727
root: string;
2828
// Path to the OpenNext static assets directory
2929
assets: string;
30-
// Path to the app's `.next` directory in the OpenNext output directory
31-
dotNext: string;
3230
// Path to the application standalone root directory
3331
standaloneRoot: string;
3432
// Path to the application standalone directory (where `next build` saves the standalone app)
@@ -92,7 +90,6 @@ export function getConfig(projectOpts: ProjectOptions): Config {
9290
output: {
9391
root: projectOpts.outputDir,
9492
assets: join(projectOpts.outputDir, "assets"),
95-
dotNext,
9693
standaloneRoot,
9794
standaloneApp,
9895
standaloneAppDotNext,

0 commit comments

Comments
 (0)