diff --git a/.changeset/light-llamas-cut.md b/.changeset/light-llamas-cut.md new file mode 100644 index 000000000..42f66ab19 --- /dev/null +++ b/.changeset/light-llamas-cut.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/cloudflare": patch +--- + +fix: support Next 14 experimental.serverComponentsExternalPackages diff --git a/packages/cloudflare/src/cli/build/utils/workerd.ts b/packages/cloudflare/src/cli/build/utils/workerd.ts index 4e9fc7464..560025ffd 100644 --- a/packages/cloudflare/src/cli/build/utils/workerd.ts +++ b/packages/cloudflare/src/cli/build/utils/workerd.ts @@ -81,7 +81,9 @@ export async function copyWorkerdPackages(options: BuildOptions, nodePackages: M // Copy full external packages when they use "workerd" build condition const nextConfig = loadConfig(path.join(options.appBuildOutputPath, ".next")); - const externalPackages = nextConfig.serverExternalPackages ?? []; + const externalPackages = + // @ts-expect-error In Next 14 its under experimental.serverComponentsExternalPackages + nextConfig.serverExternalPackages ?? nextConfig.experimental.serverComponentsExternalPackages ?? []; for (const [src, dst] of nodePackages.entries()) { try { const pkgJson = JSON.parse(await fs.readFile(path.join(src, "package.json"), "utf8"));