Skip to content

Commit 89cd3a5

Browse files
committed
comments
1 parent e5cdea4 commit 89cd3a5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

packages/cloudflare/src/cli/build/patches/ast/vercel-og.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ fix: |-
2020
"next/dist/compiled/@vercel/og/index.edge.js"
2121
`;
2222

23+
/**
24+
* Patches Node.js imports for the library to be Edge imports.
25+
*
26+
* @param root Root node.
27+
* @returns Results of applying the rule.
28+
*/
2329
export function patchVercelOgImport(root: SgNode) {
2430
return applyRule(vercelOgImportRule, root);
2531
}
@@ -46,6 +52,12 @@ fix: |-
4652
var fallbackFont = getFallbackFont()
4753
`;
4854

55+
/**
56+
* Patches the default font fetching to use a .bin import.
57+
*
58+
* @param root Root node.
59+
* @returns Results of applying the rule.
60+
*/
4961
export function patchVercelOgFallbackFont(root: SgNode) {
5062
return applyRule(vercelOgFallbackFontRule, root);
5163
}

packages/cloudflare/src/cli/build/patches/investigated/patch-vercel-og-library.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ import { patchVercelOgFallbackFont, patchVercelOgImport } from "../ast/vercel-og
1010

1111
type TraceInfo = { version: number; files: string[] };
1212

13+
/**
14+
* Patches the usage of @vercel/og to be compatible with Cloudflare Workers.
15+
*
16+
* This involves;
17+
* - Ensuring the edge version is available in the OpenNext node_modules.
18+
* - Changing node imports for the library to edge imports.
19+
* - Changing font fetches in the library to use .bin imports.
20+
*
21+
* @param buildOpts Build options.
22+
*/
1323
export function patchVercelOgLibrary(buildOpts: BuildOptions) {
1424
const { appBuildOutputPath, outputDir } = buildOpts;
1525

0 commit comments

Comments
 (0)