From a4e74eb5549cec37d99e72390912df97a77e77a0 Mon Sep 17 00:00:00 2001
From: Sadegh Barati <sadeghbaratiwork@gmail.com>
Date: Tue, 13 Feb 2024 22:56:41 +0330
Subject: [PATCH 1/2] fix: json5 `parse` is not a function

---
 src/loader.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/loader.ts b/src/loader.ts
index edc7455..166286f 100644
--- a/src/loader.ts
+++ b/src/loader.ts
@@ -331,8 +331,8 @@ async function resolveConfig<
     const { parse } = await import("jsonc-parser");
     res.config = parse(await readFile(res.configFile!, "utf8"));
   } else if (res.configFile!.endsWith(".json5")) {
-    const { parse } = await import("json5");
-    res.config = parse(await readFile(res.configFile!, "utf8"));
+    const json5 = await import("json5").then(m => m.default);
+    res.config = json5.parse(await readFile(res.configFile!, "utf8"));
   } else {
     res.config = options.jiti!(res.configFile!);
   }

From 631863e9306ff7b5b75a3c77be9bdccf8c70fef8 Mon Sep 17 00:00:00 2001
From: Pooya Parsa <pooya@pi0.io>
Date: Wed, 14 Feb 2024 13:34:01 +0100
Subject: [PATCH 2/2] update

---
 src/loader.ts | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/loader.ts b/src/loader.ts
index 166286f..6110dbc 100644
--- a/src/loader.ts
+++ b/src/loader.ts
@@ -331,8 +331,10 @@ async function resolveConfig<
     const { parse } = await import("jsonc-parser");
     res.config = parse(await readFile(res.configFile!, "utf8"));
   } else if (res.configFile!.endsWith(".json5")) {
-    const json5 = await import("json5").then(m => m.default);
-    res.config = json5.parse(await readFile(res.configFile!, "utf8"));
+    const parse = await import("json5").then(
+      (m) => m.parse || m.default?.parse || m.default,
+    );
+    res.config = parse(await readFile(res.configFile!, "utf8"));
   } else {
     res.config = options.jiti!(res.configFile!);
   }