Skip to content

Commit eedbe2b

Browse files
authored
perf: minify the generated bundle by default (#714)
1 parent 3d8fb0c commit eedbe2b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.changeset/giant-books-dream.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+
perf: minify the generated bundle by default

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const optionalDependencies = [
4848
export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
4949
patches.copyPackageCliFiles(packageDistDir, buildOpts);
5050

51-
const { appPath, outputDir, monorepoRoot } = buildOpts;
51+
const { appPath, outputDir, monorepoRoot, debug } = buildOpts;
5252
const baseManifestPath = path.join(
5353
outputDir,
5454
"server-functions/default",
@@ -76,7 +76,11 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
7676
outfile: openNextServerBundle,
7777
format: "esm",
7878
target: "esnext",
79-
minify: false,
79+
// Minify code as much as possible but stay safe by not renaming identifiers
80+
minifyWhitespace: !debug,
81+
minifyIdentifiers: false,
82+
minifySyntax: !debug,
83+
legalComments: "none",
8084
metafile: true,
8185
// Next traces files using the default conditions from `nft` (`node`, `require`, `import` and `default`)
8286
//

0 commit comments

Comments
 (0)