Skip to content

Commit

Permalink
feat(debug): never minify in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Nov 14, 2024
1 parent 009332b commit 47a3e11
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/open-next/src/build/bundleNextServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ const externals = [
"next/dist/compiled/next-server",
];

export async function bundleNextServer(outputDir: string, appPath: string) {
export async function bundleNextServer(
outputDir: string,
appPath: string,
{ debug = false },
) {
const require = createRequire(`${appPath}/package.json`);
const entrypoint = require.resolve("next/dist/esm/server/next-server.js");

Expand All @@ -54,7 +58,7 @@ export async function bundleNextServer(outputDir: string, appPath: string) {
// packages: "external",
format: "cjs",
external: externals,
minify: true,
minify: !debug,
outfile: path.join(outputDir, "next-server.runtime.prod.js"),
sourcemap: false,
plugins: [
Expand Down
4 changes: 3 additions & 1 deletion packages/open-next/src/build/createServerBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ async function generateBundle(
// Bundle next server if necessary
const isBundled = fnOptions.experimentalBundledNextServer ?? false;
if (isBundled) {
await bundleNextServer(path.join(outputPath, packagePath), appPath);
await bundleNextServer(path.join(outputPath, packagePath), appPath, {
debug: options.debug,
});
}

// Copy middleware
Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/build/edge/createEdgeBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ globalThis.AsyncLocalStorage = AsyncLocalStorage;
outfile,
allowOverwrite: true,
bundle: true,
minify: true,
minify: !options.debug,
platform: "node",
format: "esm",
conditions: ["workerd", "worker", "browser"],
Expand Down

0 comments on commit 47a3e11

Please sign in to comment.