@aziontech/opennextjs-azion
Version:
Azion builder for Next.js apps
31 lines (30 loc) • 2.78 kB
TypeScript
/**
* This code was originally copied and modified from the @opennextjs/cloudflare repository.
* Significant changes have been made to adapt it for use with Azion.
*/
import { applyRule, SgNode } from "@opennextjs/aws/build/patch/astCodePatcher.js";
export declare const vercelOgImportRule = "\nrule:\n pattern: $NODE\n kind: string\n regex: \"next/dist/compiled/@vercel/og/index\\\\.node\\\\.js\"\ninside:\n kind: arguments\n inside:\n kind: call_expression\n stopBy: end\n has:\n field: function\n regex: \"import\"\n\nfix: |-\n \"next/dist/compiled/@vercel/og/index.edge.js\"\n";
/**
* Patches Node.js imports for the library to be Edge imports.
*
* @param root Root node.
* @returns Results of applying the rule.
*/
export declare function patchVercelOgImport(root: SgNode): {
edits: import("@opennextjs/aws/build/patch/astCodePatcher").Edit[];
matches: SgNode[];
};
export declare const vercelOgFallbackFontRule = "\nrule:\n kind: variable_declaration\n all:\n - has:\n kind: variable_declarator\n has:\n kind: identifier\n regex: ^fallbackFont$\n - has:\n kind: call_expression\n pattern: fetch(new URL(\"$PATH\", $$$REST))\n stopBy: end\n\nfix: |-\n async function getFallbackFont() {\n // .bin is used so that a loader does not need to be configured for .ttf files\n return (await import(\"$PATH.bin\")).default;\n }\n\n var fallbackFont = getFallbackFont();\n";
/**
* Patches the default font fetching to use a .bin import.
*
* @param root Root node.
* @returns Results of applying the rule.
*/
export declare function patchVercelOgFallbackFont(root: SgNode): {
edits: import("@opennextjs/aws/build/patch/astCodePatcher").Edit[];
matches: SgNode[];
};
export declare const vercelOgYogaRule = "\nrule:\n pattern: var initializedResvg = initWasm(resvg_wasm);\n\nfix: |-\n async function loadWasm(mod) {\n if (typeof mod === \"string\" && mod.startsWith(\"file://\")) {\n const res = await fetch(mod); \n return await res.arrayBuffer(); \n }\n if (mod instanceof Response) {\n return await mod.arrayBuffer();\n }\n return mod; \n }\n const resvg_wasm_bytes = await loadWasm(resvg_wasm);\n const initializedResvg = initWasm(resvg_wasm_bytes);\n";
export declare const vercelOgYogaSecondRule = "\nrule:\n any:\n - pattern: var initializedYoga = initYoga(yoga_wasm).then((yoga2) => Ll(yoga2));\n - pattern: var initializedYoga = initYoga(yoga_wasm).then(yoga2 => Ll(yoga2));\n\nfix: |-\n const yoga_wasm_bytes = await loadWasm(yoga_wasm);\n const initializedYoga = initYoga(yoga_wasm_bytes).then(yoga2 => Ll(yoga2));\n";
export declare function patchVercelOgYoga(root: SgNode): ReturnType<typeof applyRule>;