Don't dynamically import resvg

Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
This commit is contained in:
Joshua Castle
2024-03-24 15:11:16 -07:00
parent 793aefd381
commit 948f100c41
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -6,6 +6,7 @@ const fs = tslib_1.__importStar(require("fs"));
const fsp = tslib_1.__importStar(require("fs/promises"));
const object_hash_1 = tslib_1.__importDefault(require("object-hash"));
const path_1 = tslib_1.__importDefault(require("path"));
const resvg_js_1 = require("@resvg/resvg-js");
class ImageGenerator {
args;
satori;
@@ -28,8 +29,7 @@ class ImageGenerator {
const absolutePath = path_1.default.join(this.outDir, imageName);
const relativePath = path_1.default.join('/', this.args.dir, absolutePath.slice(this.outDir.length));
const svg = await this.satori(element, options);
const { Resvg } = await import('@resvg/resvg-js').then(module => module);
const pngBuffer = new Resvg(svg).render().asPng();
const pngBuffer = new resvg_js_1.Resvg(svg).render().asPng();
await fsp.writeFile(absolutePath, pngBuffer);
const url = new URL(this.args.websiteUrl);
url.pathname = relativePath;
+1 -1
View File
@@ -6,6 +6,7 @@ import React from 'react'
import type Satori from 'satori'
import { type SatoriOptions } from 'satori'
import { Resvg } from '@resvg/resvg-js'
export type ImageGeneratorOptions = SatoriOptions
@@ -55,7 +56,6 @@ export class ImageGenerator {
)
const svg = await this.satori(element, options)
const { Resvg } = await import('@resvg/resvg-js').then(module => module)
const pngBuffer = new Resvg(svg).render().asPng()
await fsp.writeFile(absolutePath, pngBuffer)