Skip to content

Commit 0c45b0b

Browse files
create a wrangler.json instead of a wrangler.jsonc (#227)
1 parent 0ee77b2 commit 0c45b0b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Diff for: .changeset/lazy-balloons-report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"@opennextjs/cloudflare": patch
33
---
44

5-
check and create a `wrangler.jsonc` file for the user in case a `wrangler.(toml|json|jsonc)` file is not already present
5+
check and create a `wrangler.json` file for the user in case a `wrangler.(toml|json|jsonc)` file is not already present
66

77
also introduce a new `--skipWranglerConfigCheck` cli flag and a `SKIP_WRANGLER_CONFIG_CHECK`
88
environment variable that allows users to opt out of the above check (since developers might

Diff for: packages/cloudflare/src/cli/build/index.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,16 @@ function ensureCloudflareConfig(config: OpenNextConfig) {
184184
}
185185

186186
/**
187-
* Creates a `wrangler.jsonc` file for the user if a wrangler config file doesn't already exist,
187+
* Creates a `wrangler.json` file for the user if a wrangler config file doesn't already exist,
188188
* but only after asking for the user's confirmation.
189189
*
190190
* If the user refuses a warning is shown (which offers ways to opt out of this check to the user).
191191
*
192+
* Note: we generate a wrangler.json file with comments instead of using the jsonc extension,
193+
* we decided to do that since json is more common than jsonc, wrangler also parses
194+
* them in the same way and we also expect developers to associate `wrangler.json`
195+
* files to the jsonc language
196+
*
192197
* @param projectOpts The options for the project
193198
*/
194199
async function createWranglerConfigIfNotExistent(projectOpts: ProjectOptions): Promise<void> {
@@ -201,8 +206,6 @@ async function createWranglerConfigIfNotExistent(projectOpts: ProjectOptions): P
201206
return;
202207
}
203208

204-
const wranglerConfigPath = join(projectOpts.sourceDir, "wrangler.jsonc");
205-
206209
const answer = await askConfirmation(
207210
"No `wrangler.(toml|json|jsonc)` config file found, do you want to create one?"
208211
);
@@ -238,7 +241,7 @@ async function createWranglerConfigIfNotExistent(projectOpts: ProjectOptions): P
238241
);
239242
}
240243

241-
writeFileSync(wranglerConfigPath, wranglerConfigContent);
244+
writeFileSync(join(projectOpts.sourceDir, "wrangler.json"), wranglerConfigContent);
242245
}
243246

244247
function getAppNameFromPackageJson(sourceDir: string): string | undefined {

0 commit comments

Comments
 (0)