Skip to content

Commit a3337e0

Browse files
authored
refactor: getBuildId takes the BuildOptions (#712)
1 parent bef51ed commit a3337e0

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function createCacheAssets(options: buildHelper.BuildOptions) {
6262

6363
const { appBuildOutputPath, outputDir } = options;
6464
const packagePath = buildHelper.getPackagePath(options);
65-
const buildId = buildHelper.getBuildId(appBuildOutputPath);
65+
const buildId = buildHelper.getBuildId(options);
6666
let useTagCache = false;
6767

6868
// Copy pages to cache folder

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,7 @@ export async function generateOutput(options: BuildOptions) {
292292
const patterns = "patterns" in value ? value.patterns : ["*"];
293293
patterns.forEach((pattern) => {
294294
behaviors.push({
295-
pattern: prefixer(
296-
pattern.replace(/BUILD_ID/, getBuildId(appBuildOutputPath)),
297-
),
295+
pattern: prefixer(pattern.replace(/BUILD_ID/, getBuildId(options))),
298296
origin: value.placement === "global" ? undefined : key,
299297
edgeFunction:
300298
value.placement === "global"

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,12 @@ export function getHtmlPages(dotNextPath: string) {
252252
.reduce((acc, page) => acc.add(page), new Set<string>());
253253
}
254254

255-
export function getBuildId(dotNextPath: string) {
255+
export function getBuildId(options: BuildOptions) {
256256
return fs
257-
.readFileSync(path.join(dotNextPath, ".next/BUILD_ID"), "utf-8")
257+
.readFileSync(
258+
path.join(options.appBuildOutputPath, ".next/BUILD_ID"),
259+
"utf-8",
260+
)
258261
.trim();
259262
}
260263

0 commit comments

Comments
 (0)