Skip to content

perf: minify the generated bundle by default #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/giant-books-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

perf: minify the generated bundle by default
8 changes: 6 additions & 2 deletions packages/cloudflare/src/cli/build/bundle-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const optionalDependencies = [
export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
patches.copyPackageCliFiles(packageDistDir, buildOpts);

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