Skip to content

Commit e6040bc

Browse files
conico974Nicolas Dorseuil
andauthored
Feat: Disable config validation (#675)
* add an option to not throw on config error * changeset * review --------- Co-authored-by: Nicolas Dorseuil <[email protected]>
1 parent ead6ddc commit e6040bc

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

.changeset/fresh-crews-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
add a `cloudflare.dangerousDisableConfigValidation` config option to not throw on validation of the config

packages/cloudflare/src/api/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ interface OpenNextConfig extends AwsOpenNextConfig {
116116
* @default true
117117
*/
118118
useWorkerdCondition?: boolean;
119+
120+
/**
121+
* Disable throwing an error when the config validation fails.
122+
* This is useful for overriding some of the default provided by cloudflare.
123+
* **USE AT YOUR OWN RISK**
124+
* @default false
125+
*/
126+
dangerousDisableConfigValidation?: boolean;
119127
};
120128
}
121129

packages/cloudflare/src/cli/build/utils/ensure-cf-config.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export function ensureCloudflareConfig(config: OpenNextConfig) {
3636
}
3737

3838
if (Object.values(requirements).some((satisfied) => !satisfied)) {
39-
throw new Error(
39+
const errorMessage =
4040
"The `open-next.config.ts` should have a default export like this:\n\n" +
41-
`{
41+
`{
4242
default: {
4343
override: {
4444
wrapper: "cloudflare-node",
@@ -61,7 +61,11 @@ export function ensureCloudflareConfig(config: OpenNextConfig) {
6161
queue: "dummy" | "direct" | function,
6262
},
6363
},
64-
}\n\n`.replace(/^ {8}/gm, "")
65-
);
64+
}\n\n`.replace(/^ {8}/gm, "");
65+
if (config.cloudflare?.dangerousDisableConfigValidation) {
66+
logger.warn(errorMessage);
67+
return;
68+
}
69+
throw new Error(errorMessage);
6670
}
6771
}

0 commit comments

Comments
 (0)