From 4866f3b2c31f69a4167f388ccdf2eccbbdb27e0a Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 1 Aug 2025 08:54:51 +0200 Subject: [PATCH 1/2] fix: --noMinify stop minifying the bundle --- packages/cloudflare/src/cli/build/build.ts | 2 +- packages/cloudflare/src/cli/build/bundle-server.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/cloudflare/src/cli/build/build.ts b/packages/cloudflare/src/cli/build/build.ts index bfcf726d..da6e3bbf 100644 --- a/packages/cloudflare/src/cli/build/build.ts +++ b/packages/cloudflare/src/cli/build/build.ts @@ -83,7 +83,7 @@ export async function build( await compileDurableObjects(options); - await bundleServer(options); + await bundleServer(options, projectOpts); if (!projectOpts.skipWranglerConfigCheck) { await createWranglerConfigIfNotExistent(projectOpts); diff --git a/packages/cloudflare/src/cli/build/bundle-server.ts b/packages/cloudflare/src/cli/build/bundle-server.ts index cd08a9e6..a00d250d 100644 --- a/packages/cloudflare/src/cli/build/bundle-server.ts +++ b/packages/cloudflare/src/cli/build/bundle-server.ts @@ -8,6 +8,7 @@ import { ContentUpdater } from "@opennextjs/aws/plugins/content-updater.js"; import { build, type Plugin } from "esbuild"; import { getOpenNextConfig } from "../../api/config.js"; +import type { ProjectOptions } from "../project-options.js"; import { patchVercelOgLibrary } from "./patches/ast/patch-vercel-og-library.js"; import { patchWebpackRuntime } from "./patches/ast/webpack-runtime.js"; import { inlineDynamicRequires } from "./patches/plugins/dynamic-requires.js"; @@ -44,7 +45,7 @@ const optionalDependencies = [ /** * Bundle the Open Next server. */ -export async function bundleServer(buildOpts: BuildOptions): Promise { +export async function bundleServer(buildOpts: BuildOptions, projectOpts: ProjectOptions): Promise { copyPackageCliFiles(packageDistDir, buildOpts); const { appPath, outputDir, monorepoRoot, debug } = buildOpts; @@ -76,9 +77,9 @@ export async function bundleServer(buildOpts: BuildOptions): Promise { format: "esm", target: "esnext", // Minify code as much as possible but stay safe by not renaming identifiers - minifyWhitespace: !debug, + minifyWhitespace: projectOpts.minify && !debug, minifyIdentifiers: false, - minifySyntax: !debug, + minifySyntax: projectOpts.minify && !debug, legalComments: "none", metafile: true, // Next traces files using the default conditions from `nft` (`node`, `require`, `import` and `default`) From 36688a67555efe1bdaadb680f3d5267d4b7c114a Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 1 Aug 2025 08:57:01 +0200 Subject: [PATCH 2/2] fixup! changeset --- .changeset/seven-bats-push.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/seven-bats-push.md diff --git a/.changeset/seven-bats-push.md b/.changeset/seven-bats-push.md new file mode 100644 index 00000000..23ccb520 --- /dev/null +++ b/.changeset/seven-bats-push.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/cloudflare": patch +--- + +fix: --noMinify stop minifying the bundle