From 948f100c4176a7272d41dcf2943905d043373ab7 Mon Sep 17 00:00:00 2001 From: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:11:16 -0700 Subject: [PATCH] Don't dynamically import resvg Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> --- lib/server/imageGenerator.js | 4 ++-- src/server/imageGenerator.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/server/imageGenerator.js b/lib/server/imageGenerator.js index b79f93e..60fc9c4 100644 --- a/lib/server/imageGenerator.js +++ b/lib/server/imageGenerator.js @@ -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; diff --git a/src/server/imageGenerator.ts b/src/server/imageGenerator.ts index 9c6dd7b..e5c090a 100644 --- a/src/server/imageGenerator.ts +++ b/src/server/imageGenerator.ts @@ -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)