Skip to content

Commit 65424fa

Browse files
authored
fix: improve json import (anuraghazra#2190)
1 parent f7a2b21 commit 65424fa

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/cards/wakatime-card.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@ import { wakatimeCardLocales } from "../translations.js";
1818
* since vercel is using v16.14.0 which does not yet support json imports without the
1919
* --experimental-json-modules flag.
2020
*/
21-
import { createRequire } from "module";
22-
const require = createRequire(import.meta.url);
23-
const languageColors = require("../common/languageColors.json"); // now works
21+
import { readFileSync } from "fs";
22+
import path from "path";
23+
import { fileURLToPath } from "url";
24+
const __filename = fileURLToPath(import.meta.url);
25+
const __dirname = path.dirname(__filename);
26+
const languageColors = JSON.parse(
27+
readFileSync(
28+
path.resolve(__dirname, "../common/languageColors.json"),
29+
"utf8",
30+
),
31+
);
2432

2533
/**
2634
* Creates the no coding activity SVG node.

0 commit comments

Comments
 (0)