diff --git a/.changeset/whole-spiders-stay.md b/.changeset/whole-spiders-stay.md new file mode 100644 index 00000000..ea20981d --- /dev/null +++ b/.changeset/whole-spiders-stay.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/cloudflare": patch +--- + +make the "require" patch optional diff --git a/packages/cloudflare/src/cli/build/bundle-server.ts b/packages/cloudflare/src/cli/build/bundle-server.ts index 1d83ccec..b002c154 100644 --- a/packages/cloudflare/src/cli/build/bundle-server.ts +++ b/packages/cloudflare/src/cli/build/bundle-server.ts @@ -174,7 +174,9 @@ export async function bundleServer(buildOpts: BuildOptions): Promise { */ export async function updateWorkerBundledCode(workerOutputFile: string): Promise { const code = await readFile(workerOutputFile, "utf8"); - const patchedCode = await patchCodeWithValidations(code, [["require", patches.patchRequire]]); + const patchedCode = await patchCodeWithValidations(code, [ + ["require", patches.patchRequire, { isOptional: true }], + ]); await writeFile(workerOutputFile, patchedCode); } diff --git a/packages/cloudflare/src/cli/build/patches/plugins/open-next.ts b/packages/cloudflare/src/cli/build/patches/plugins/open-next.ts index 2939a524..bca9cb67 100644 --- a/packages/cloudflare/src/cli/build/patches/plugins/open-next.ts +++ b/packages/cloudflare/src/cli/build/patches/plugins/open-next.ts @@ -19,8 +19,6 @@ export function patchResolveCache(updater: ContentUpdater, buildOpts: BuildOptio path.join(outputPath, packagePath, `index.mjs`) ); - console.error({ index: indexPath }); - return updater.updateContent("patch-resolve-cache", [ { field: { diff --git a/packages/cloudflare/src/cli/build/utils/apply-patches.ts b/packages/cloudflare/src/cli/build/utils/apply-patches.ts index fe080d41..599158da 100644 --- a/packages/cloudflare/src/cli/build/utils/apply-patches.ts +++ b/packages/cloudflare/src/cli/build/utils/apply-patches.ts @@ -25,6 +25,5 @@ export async function patchCodeWithValidations( } } - console.log(`All ${patches.length} patches applied\n`); return patchedCode; }