Skip to content

Commit 71a1f91

Browse files
committed
review
1 parent 443a4c5 commit 71a1f91

File tree

4 files changed

+24
-29
lines changed

4 files changed

+24
-29
lines changed

packages/open-next/src/overrides/incrementalCache/fs-dev.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
import type { IncrementalCache } from "types/overrides.js";
2-
31
import fs from "node:fs/promises";
42
import path from "node:path";
53

4+
import type { IncrementalCache } from "types/overrides.js";
5+
import { getOutputDir } from "utils/normalize-path";
6+
67
const buildId = process.env.NEXT_BUILD_ID;
7-
const basePath = path.join(
8-
globalThis.monorepoPackagePath
9-
.split("/")
10-
.filter(Boolean)
11-
.map(() => "../")
12-
.join(""),
13-
`../../cache/${buildId}`,
14-
);
8+
const basePath = path.join(getOutputDir(), `../../cache/${buildId}`);
159

1610
const getCacheKey = (key: string) => {
1711
return path.join(basePath, `${key}.cache`);

packages/open-next/src/overrides/tagCache/fs-dev.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import type { TagCache } from "types/overrides";
2-
31
import fs from "node:fs";
42
import path from "node:path";
53

4+
import type { TagCache } from "types/overrides";
5+
import { getOutputDir } from "utils/normalize-path";
6+
67
const tagFile = path.join(
7-
globalThis.monorepoPackagePath
8-
.split("/")
9-
.filter(Boolean)
10-
.map(() => "../")
11-
.join(""),
8+
getOutputDir(),
129
"../../dynamodb-provider/dynamodb-cache.json",
1310
);
1411
const tagContent = fs.readFileSync(tagFile, "utf-8");

packages/open-next/src/overrides/wrappers/express-dev.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,16 @@ import express from "express";
33

44
import type { StreamCreator } from "types/open-next.js";
55
import type { WrapperHandler } from "types/overrides.js";
6-
7-
const outputDir = path.join(
8-
globalThis.monorepoPackagePath
9-
.split("/")
10-
.filter(Boolean)
11-
.map(() => "../")
12-
.join(""),
13-
"../../",
14-
);
6+
import { getOutputDir } from "utils/normalize-path";
157

168
const wrapper: WrapperHandler = async (handler, converter) => {
179
const app = express();
1810
// To serve static assets
19-
app.use(express.static(path.join(outputDir, "assets")));
11+
app.use(express.static(path.join(getOutputDir(), "../../assets")));
2012

2113
const imageHandlerPath = path.join(
22-
outputDir,
23-
"image-optimization-function/index.mjs",
14+
getOutputDir(),
15+
"../../image-optimization-function/index.mjs",
2416
);
2517

2618
const imageHandler = await import(imageHandlerPath).then((m) => m.handler);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
import path from "node:path";
2+
13
export function normalizePath(path: string) {
24
return path.replace(/\\/g, "/");
35
}
6+
7+
export function getOutputDir() {
8+
return path.join(
9+
globalThis.monorepoPackagePath
10+
.split("/")
11+
.filter(Boolean)
12+
.map(() => "..")
13+
.join("/"),
14+
);
15+
}

0 commit comments

Comments
 (0)