Skip to content

🎥 Make videos programmatically with React

google fonts bun

Jonny Burgerf0e16a43d40f
diff --git a/packages/google-fonts/package.json b/packages/google-fonts/package.json
index 78b809a5c2..85e7375060 100644
--- a/packages/google-fonts/package.json
+++ b/packages/google-fonts/package.json
@@ -7,7 +7,7 @@
"scripts": {
"build": "pnpm run generate && rollup --config rollup.config.js",
"watch": "tsc -w",
- "generate": "ts-node scripts/generate.ts && ts-node scripts/generate-index.ts",
+ "generate": "bun scripts/generate.ts && bun scripts/generate-index.ts",
"prepublishOnly": "node ensure-generation.js"
},
"license": "SEE LICENSE IN LICENSE.md",
@@ -19,7 +19,6 @@
"@types/css-font-loading-module": "^0.0.7",
"@types/node": "18.14.6",
"@types/prettier": "^2.7.1",
- "got": "^11",
"postcss": "^8.4.31",
"prettier": "3.1.1",
"rollup": "^2.70.1",
diff --git a/packages/google-fonts/scripts/generate.ts b/packages/google-fonts/scripts/generate.ts
index 4d8ea676fe..2b532fad29 100644
--- a/packages/google-fonts/scripts/generate.ts
+++ b/packages/google-fonts/scripts/generate.ts
@@ -1,6 +1,5 @@
import fs, { mkdirSync } from "node:fs";
import path from "path";
-import got from "got";
import postcss from "postcss";
type FontInfo = {
@@ -40,19 +39,21 @@ const generate = async (font: Font) => {
let css: null | string = null;
let fontFamily: null | string = replaceDigitsWithWords(unquote(font.family));
let cssFile = path.resolve(CSS_CACHE_DIR, cssname);
+
if (!fs.existsSync(cssFile)) {
// Get from url with user agent that support woff2
- const res = await got.get(url, {
+ const res = await fetch(url, {
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36",
},
});
+ const body = await res.text();
// Save to cache
- await fs.promises.writeFile(cssFile, res.body);
+ await fs.promises.writeFile(cssFile, body);
- css = res.body;
+ css = body;
} else {
// Read css from cache
css = await fs.promises.readFile(cssFile, "utf-8");
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f346e3bcd0..be98faaf25 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1059,9 +1059,6 @@ importers:
'@types/prettier':
specifier: ^2.7.1
version: 2.7.1
- got:
- specifier: ^11
- version: 11.8.5
postcss:
specifier: ^8.4.31
version: 8.4.31