Thanks to visit codestin.com
Credit goes to github.com

Skip to content

return meta files from createAssets() #748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 20, 2025
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
7 changes: 7 additions & 0 deletions packages/open-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
"types": "./dist/*.d.ts"
}
},
"typesVersions": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would "types": "dist/*" work here?

Could the problem be that we import path.js instead of path (would be awesome to be able to drop the .js but it might be a breaking change)

Anyway do not spend too much time on this if you have a working config.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could the problem be that we import path.js instead of path (would be awesome to be able to drop the .js but it might be a breaking change)

I don't think so, i've tested this on a test repo that i had and it worked. I was even able to drop the .js.

If we need typesVersions to not break compatibility i'm fine with it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unfortunately same problem

"*": {
"*": [
"dist/*"
]
}
},
"keywords": [],
"author": "",
"files": [
Expand Down
11 changes: 4 additions & 7 deletions packages/open-next/src/build/createAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from "node:fs";
import path from "node:path";

import logger from "../logger.js";
import type { TagCacheMetaFile } from "../types/cache.js";
import { isBinaryContentType } from "../utils/binary.js";
import * as buildHelper from "./helper.js";

Expand Down Expand Up @@ -55,7 +56,7 @@ export function createStaticAssets(options: buildHelper.BuildOptions) {
* Create the cache assets.
*
* @param options Build options.
* @returns Whether tag cache is used.
* @returns Whether the tag cache is used, and the meta files collected.
*/
export function createCacheAssets(options: buildHelper.BuildOptions) {
logger.info("Bundling cache assets...");
Expand Down Expand Up @@ -157,11 +158,7 @@ export function createCacheAssets(options: buildHelper.BuildOptions) {
});

// We need to traverse the cache to find every .meta file
const metaFiles: {
tag: { S: string };
path: { S: string };
revalidatedAt: { N: string };
}[] = [];
const metaFiles: TagCacheMetaFile[] = [];

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

return { useTagCache };
return { useTagCache, metaFiles };
}
6 changes: 6 additions & 0 deletions packages/open-next/src/types/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ export interface Meta {
headers?: Record<string, undefined | string | string[]>;
postponed?: string;
}

export type TagCacheMetaFile = {
tag: { S: string };
path: { S: string };
revalidatedAt: { N: string };
};
Loading