Skip to content
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
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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this function should not be necessary in the future. Next should provide us directly with an already bundled NextServer in the future

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