Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"glob": "catalog:",
"globals": "catalog:",
"next": "catalog:",
"package-manager-detector": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:",
"typescript-eslint": "catalog:",
Expand Down
19 changes: 11 additions & 8 deletions packages/cloudflare/src/cli/build/build-next-app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type AgentName as PackageManager, detect } from "package-manager-detector";
import { execSync } from "node:child_process";

/**
Expand All @@ -7,17 +8,19 @@ import { execSync } from "node:child_process";
*
* @param nextAppDir the directory of the app to build
*/
export function buildNextjsApp(nextAppDir: string): void {
runNextBuildCommand("pnpm", nextAppDir);
export async function buildNextjsApp(nextAppDir: string): Promise<void> {
const pm = await detect();

if (!pm) {
throw new Error("Fatal Error: package manager detection failed, aborting");
}

runNextBuildCommand(pm.name, nextAppDir);
}

// equivalent to: https://github.com/sst/open-next/blob/f61b0e94/packages/open-next/src/build.ts#L175-L186
function runNextBuildCommand(
// let's keep things simple and just support only pnpm for now
packager: "pnpm" /*"npm" | "yarn" | "pnpm" | "bun"*/,
nextAppDir: string
) {
const command = ["bun", "npm"].includes(packager) ? `${packager} next build` : `${packager} next build`;
function runNextBuildCommand(packager: PackageManager, nextAppDir: string) {
const command = `${packager === "npm" ? "npx" : packager} next build`;
execSync(command, {
stdio: "inherit",
cwd: nextAppDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/src/cli/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { rm } from "node:fs/promises";
export async function build(appDir: string, opts: BuildOptions): Promise<void> {
if (!opts.skipBuild) {
// Build the next app
buildNextjsApp(appDir);
await buildNextjsApp(appDir);
}

if (!containsDotNextDir(appDir)) {
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ catalog:
"globals": ^15.9.0
"typescript-eslint": ^8.7.0
"eslint-plugin-unicorn": ^55.0.0
"package-manager-detector": ^0.2.0