Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a909ff

Browse files
authored
build: fix wakatime json import bug (anuraghazra#2050)
* build: fix vercel node version* build: remove engine property* fix: add json import workarroundThis commit adds a workaround for importing the `languageColors` JSONfile. This needed to be done since Vercel uses v16.4, which does notsupport JSON file importing without the `experimental-json-modules`flag. Seehttps://simonplend.com/import-json-in-es-modules/for more information. The workaround can be found [here](https://stackoverflow.com/questions/66726365/how-should-i-import-json-in-node).
1 parentdbf6560 commit9a909ff

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

‎package-lock.json

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
},
1717
"author":"Anurag Hazra",
1818
"license":"MIT",
19-
"engines": {
20-
"node":">=13"
21-
},
2219
"devDependencies": {
2320
"@actions/core":"^1.2.4",
2421
"@actions/github":"^4.0.0",

‎src/cards/wakatime-card.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import{Card}from"../common/Card.js";
33
import{createProgressNode}from"../common/createProgressNode.js";
44
import{I18n}from"../common/I18n.js";
5-
importlanguageColorsfrom"../common/languageColors.json"assert{type: "json"};
65
import{
76
clampValue,
87
flexLayout,
@@ -11,6 +10,18 @@ import {
1110
}from"../common/utils.js";
1211
import{getStyles}from"../getStyles.js";
1312
import{wakatimeCardLocales}from"../translations.js";
13+
14+
/** Import language colors.
15+
*
16+
*@description Here we use the workaround found in
17+
* https://stackoverflow.com/questions/66726365/how-should-i-import-json-in-node
18+
* since vercel is using v16.14.0 which does not yet support json imports without the
19+
* --experimental-json-modules flag.
20+
*/
21+
import{createRequire}from"module";
22+
constrequire=createRequire(import.meta.url);
23+
constlanguageColors=require("../common/languageColors.json");// now works
24+
1425
/**
1526
*@param {{color: string, text: string}} param0
1627
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp