Skip to content

Commit 621f414

Browse files
authored
refactor: introduce a getPackagePath helper (#711)
1 parent b4ad0f0 commit 621f414

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

packages/open-next/src/build/createAssets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function createCacheAssets(options: buildHelper.BuildOptions) {
6161
logger.info("Bundling cache assets...");
6262

6363
const { appBuildOutputPath, outputDir } = options;
64-
const packagePath = path.relative(options.monorepoRoot, appBuildOutputPath);
64+
const packagePath = buildHelper.getPackagePath(options);
6565
const buildId = buildHelper.getBuildId(appBuildOutputPath);
6666
let useTagCache = false;
6767

packages/open-next/src/build/createServerBundle.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,14 @@ export async function createServerBundle(options: buildHelper.BuildOptions) {
4747

4848
const remainingRoutes = new Set<string>();
4949

50-
const { appBuildOutputPath, monorepoRoot } = options;
51-
52-
const packagePath = path.relative(monorepoRoot, appBuildOutputPath);
50+
const { appBuildOutputPath } = options;
5351

5452
// Find remaining routes
5553
const serverPath = path.join(
5654
appBuildOutputPath,
57-
".next",
58-
"standalone",
59-
packagePath,
60-
".next",
61-
"server",
55+
".next/standalone",
56+
buildHelper.getPackagePath(options),
57+
".next/server",
6258
);
6359

6460
// Find app dir routes
@@ -118,7 +114,7 @@ async function generateBundle(
118114
// `node_modules` inside `.next/standalone`, and others inside
119115
// `.next/standalone/package/path` (ie. `.next`, `server.js`).
120116
// We need to output the handler file inside the package path.
121-
const packagePath = path.relative(monorepoRoot, appBuildOutputPath);
117+
const packagePath = buildHelper.getPackagePath(options);
122118
fs.mkdirSync(path.join(outputPath, packagePath), { recursive: true });
123119

124120
const ext = fnOptions.runtime === "deno" ? "mjs" : "cjs";

packages/open-next/src/build/helper.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,7 @@ export async function isEdgeRuntime(
389389
}
390390
return (await overrides?.wrapper?.())?.edgeRuntime;
391391
}
392+
393+
export function getPackagePath(options: BuildOptions) {
394+
return path.relative(options.monorepoRoot, options.appBuildOutputPath);
395+
}

0 commit comments

Comments
 (0)