Skip to content

Commit 67e71b9

Browse files
authored
fix: --noMinify stop minifying the bundle (#832)
1 parent d00b3a1 commit 67e71b9

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.changeset/seven-bats-push.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+
fix: --noMinify stop minifying the bundle

packages/cloudflare/src/cli/build/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export async function build(
8383

8484
await compileDurableObjects(options);
8585

86-
await bundleServer(options);
86+
await bundleServer(options, projectOpts);
8787

8888
if (!projectOpts.skipWranglerConfigCheck) {
8989
await createWranglerConfigIfNotExistent(projectOpts);

packages/cloudflare/src/cli/build/bundle-server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ContentUpdater } from "@opennextjs/aws/plugins/content-updater.js";
88
import { build, type Plugin } from "esbuild";
99

1010
import { getOpenNextConfig } from "../../api/config.js";
11+
import type { ProjectOptions } from "../project-options.js";
1112
import { patchVercelOgLibrary } from "./patches/ast/patch-vercel-og-library.js";
1213
import { patchWebpackRuntime } from "./patches/ast/webpack-runtime.js";
1314
import { inlineDynamicRequires } from "./patches/plugins/dynamic-requires.js";
@@ -44,7 +45,7 @@ const optionalDependencies = [
4445
/**
4546
* Bundle the Open Next server.
4647
*/
47-
export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
48+
export async function bundleServer(buildOpts: BuildOptions, projectOpts: ProjectOptions): Promise<void> {
4849
copyPackageCliFiles(packageDistDir, buildOpts);
4950

5051
const { appPath, outputDir, monorepoRoot, debug } = buildOpts;
@@ -76,9 +77,9 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
7677
format: "esm",
7778
target: "esnext",
7879
// Minify code as much as possible but stay safe by not renaming identifiers
79-
minifyWhitespace: !debug,
80+
minifyWhitespace: projectOpts.minify && !debug,
8081
minifyIdentifiers: false,
81-
minifySyntax: !debug,
82+
minifySyntax: projectOpts.minify && !debug,
8283
legalComments: "none",
8384
metafile: true,
8485
// Next traces files using the default conditions from `nft` (`node`, `require`, `import` and `default`)

0 commit comments

Comments
 (0)