Skip to content

Commit ac40c8c

Browse files
authored
Update the c3 template to use placeholders (#1038)
1 parent a4a2f02 commit ac40c8c

File tree

8 files changed

+107
-97
lines changed

8 files changed

+107
-97
lines changed

create-cloudflare/next/.dev.vars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Load .env.development* files when running `wrangler dev`
2+
NEXTJS_ENV=development

create-cloudflare/next/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "next",
2+
"name": "<PACKAGE_NAME>",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
@@ -13,7 +13,7 @@
1313
"cf-typegen": "wrangler types --env-interface CloudflareEnv ./cloudflare-env.d.ts"
1414
},
1515
"dependencies": {
16-
"@opennextjs/cloudflare": "^1.14.2",
16+
"@opennextjs/cloudflare": "^1.14.4",
1717
"next": "15.5.7",
1818
"react": "19.1.2",
1919
"react-dom": "19.1.2"
@@ -28,6 +28,6 @@
2828
"eslint-config-next": "15.4.6",
2929
"tailwindcss": "^4",
3030
"typescript": "^5",
31-
"wrangler": "^4.45.4"
31+
"wrangler": "^4.53.0"
3232
}
3333
}

create-cloudflare/next/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
],
2121
"paths": {
2222
"@/*": ["./src/*"]
23-
},
24-
"types": ["./cloudflare-env.d.ts", "node"]
23+
}
2524
},
2625
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
2726
"exclude": ["node_modules"]

create-cloudflare/next/wrangler.jsonc

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@
44
*/
55
{
66
"$schema": "node_modules/wrangler/config-schema.json",
7-
"name": "next",
7+
"name": "<WORKER_NAME>",
88
"main": ".open-next/worker.js",
9-
"compatibility_date": "2025-11-06",
9+
"compatibility_date": "2025-12-01",
1010
"compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],
1111
"assets": {
1212
"binding": "ASSETS",
1313
"directory": ".open-next/assets"
1414
},
15-
"observability": {
16-
"enabled": true
17-
},
1815
"images": {
1916
// Enable image optimization
2017
// see https://opennext.js.org/cloudflare/howtos/image
2118
"binding": "IMAGES"
19+
},
20+
"services": [
21+
{
22+
// Self-reference service binding, the service name must match the worker name
23+
// see https://opennext.js.org/cloudflare/caching
24+
"binding": "WORKER_SELF_REFERENCE",
25+
"service": "<WORKER_NAME>"
26+
}
27+
],
28+
"observability": {
29+
"enabled": true
2230
}
2331
}

packages/cloudflare/src/cli/build/utils/create-config-files.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ export async function createWranglerConfigIfNotExistent(projectOpts: ProjectOpti
3939
let wranglerConfig = readFileSync(join(getPackageTemplatesDirPath(), "wrangler.jsonc"), "utf8");
4040

4141
const appName = getAppNameFromPackageJson(projectOpts.sourceDir) ?? "app-name";
42-
if (appName) {
43-
wranglerConfig = wranglerConfig.replaceAll('"app-name"', JSON.stringify(appName.replaceAll("_", "-")));
44-
}
42+
43+
wranglerConfig = wranglerConfig.replaceAll('"<WORKER_NAME>"', JSON.stringify(appName.replaceAll("_", "-")));
4544

4645
const compatDate = await getLatestCompatDate();
4746
if (compatDate) {

packages/cloudflare/templates/wrangler.jsonc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
{
22
"$schema": "node_modules/wrangler/config-schema.json",
33
"main": ".open-next/worker.js",
4-
"name": "app-name",
5-
"compatibility_date": "2024-12-30",
4+
"name": "<WORKER_NAME>",
5+
"compatibility_date": "2025-12-01",
66
"compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],
77
"assets": {
88
"directory": ".open-next/assets",
99
"binding": "ASSETS"
1010
},
1111
"services": [
1212
{
13+
// Self-reference service binding, the service name must match the worker name
14+
// see https://opennext.js.org/cloudflare/caching
1315
"binding": "WORKER_SELF_REFERENCE",
14-
"service": "app-name"
16+
"service": "<WORKER_NAME>"
1517
}
1618
],
1719
"r2_buckets": [

0 commit comments

Comments
 (0)