Skip to content

Commit 773e2a8

Browse files
fix the generation of invalid/incorrect scripts for Next.js applications (#4200)
1 parent b5e62b9 commit 773e2a8

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

.changeset/tasty-teachers-lick.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
fix the generation of invalid/incorrect scripts for Next.js applications

packages/create-cloudflare/src/frameworks/next/index.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,20 @@ const config: FrameworkConfig = {
141141
generate,
142142
configure,
143143
displayName: "Next",
144-
getPackageScripts: async () => ({
145-
"pages:build": `${dlx} @cloudflare/next-on-pages@1`,
146-
"pages:deploy": `${npm} run pages:build && wrangler pages deploy .vercel/output/static`,
147-
"pages:watch": `${npx} @cloudflare/next-on-pages@1 --watch`,
148-
"pages:dev": `${npx} wrangler pages dev .vercel/output/static ${await compatDateFlag()} --compatibility-flag=nodejs_compat`,
149-
}),
144+
getPackageScripts: async () => {
145+
const isNpmOrBun = ["npm", "bun"].includes(npm);
146+
const nextOnPagesScope = isNpmOrBun ? "@cloudflare/" : "";
147+
const nextOnPagesCommand = `${nextOnPagesScope}next-on-pages`;
148+
const pmCommand = isNpmOrBun ? npx : npm;
149+
return {
150+
"pages:build": `${pmCommand} ${nextOnPagesCommand}`,
151+
"pages:deploy": `${
152+
npm === "npm" ? "npm run" : pmCommand
153+
} pages:build && wrangler pages deploy .vercel/output/static`,
154+
"pages:watch": `${pmCommand} ${nextOnPagesCommand} --watch`,
155+
"pages:dev": `${pmCommand} wrangler pages dev .vercel/output/static ${await compatDateFlag()} --compatibility-flag=nodejs_compat`,
156+
};
157+
},
150158
testFlags: [
151159
"--typescript",
152160
"--no-install",

0 commit comments

Comments
 (0)