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 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`)