Skip to content

Commit 9f3720f

Browse files
authored
return meta files from createAssets() (#748)
1 parent f96dac7 commit 9f3720f

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

packages/open-next/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
"types": "./dist/*.d.ts"
2323
}
2424
},
25+
"typesVersions": {
26+
"*": {
27+
"*": [
28+
"dist/*"
29+
]
30+
}
31+
},
2532
"keywords": [],
2633
"author": "",
2734
"files": [

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from "node:fs";
22
import path from "node:path";
33

44
import logger from "../logger.js";
5+
import type { TagCacheMetaFile } from "../types/cache.js";
56
import { isBinaryContentType } from "../utils/binary.js";
67
import * as buildHelper from "./helper.js";
78

@@ -55,7 +56,7 @@ export function createStaticAssets(options: buildHelper.BuildOptions) {
5556
* Create the cache assets.
5657
*
5758
* @param options Build options.
58-
* @returns Whether tag cache is used.
59+
* @returns Whether the tag cache is used, and the meta files collected.
5960
*/
6061
export function createCacheAssets(options: buildHelper.BuildOptions) {
6162
logger.info("Bundling cache assets...");
@@ -157,11 +158,7 @@ export function createCacheAssets(options: buildHelper.BuildOptions) {
157158
});
158159

159160
// We need to traverse the cache to find every .meta file
160-
const metaFiles: {
161-
tag: { S: string };
162-
path: { S: string };
163-
revalidatedAt: { N: string };
164-
}[] = [];
161+
const metaFiles: TagCacheMetaFile[] = [];
165162

166163
// Copy fetch-cache to cache folder
167164
const fetchCachePath = path.join(
@@ -244,5 +241,5 @@ export function createCacheAssets(options: buildHelper.BuildOptions) {
244241
({ relativePath }) => !relativePath.endsWith(".cache"),
245242
);
246243

247-
return { useTagCache };
244+
return { useTagCache, metaFiles };
248245
}

packages/open-next/src/types/cache.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ export interface Meta {
7575
headers?: Record<string, undefined | string | string[]>;
7676
postponed?: string;
7777
}
78+
79+
export type TagCacheMetaFile = {
80+
tag: { S: string };
81+
path: { S: string };
82+
revalidatedAt: { N: string };
83+
};

0 commit comments

Comments
 (0)