Skip to content

Commit a0527b3

Browse files
chore: update suncalc to v2 and adjust import path
1 parent 7c96623 commit a0527b3

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

js/loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ function loadFile (fileName) {
195195

196196
switch (extension.toLowerCase()) {
197197
case "js":
198+
case "cjs":
198199
return new Promise((resolve) => {
199200
Log.log(`Load script: ${fileName}`);
200201
script = document.createElement("script");

js/server.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ function Server (configObj) {
104104
if (dirArr[0] === "node_modules") directories.push(`/${dirArr[0]}/${dirArr[1]}`);
105105
}
106106
const uniqDirs = [...new Set(directories)];
107+
108+
// suncalc v2 ships suncalc.cjs (UMD); serve it explicitly as JavaScript
109+
// because express.static maps .cjs to application/node which browsers reject.
110+
app.get("/node_modules/suncalc/suncalc.cjs", (req, res) => {
111+
res.type("text/javascript").sendFile(path.resolve(global.root_path, "node_modules/suncalc/suncalc.cjs"));
112+
});
113+
107114
for (const directory of uniqDirs) {
108115
app.use(directory, express.static(path.resolve(global.root_path + directory)));
109116
}

js/vendor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const vendor = {
55
"weather-icons-wind.css": "node_modules/weathericons/css/weather-icons-wind.css",
66
"font-awesome.css": "css/font-awesome.css",
77
"nunjucks.js": "node_modules/nunjucks/browser/nunjucks.min.js",
8-
"suncalc.js": "node_modules/suncalc/suncalc.js",
8+
"suncalc.js": "node_modules/suncalc/suncalc.cjs",
99
"croner.js": "node_modules/croner/dist/croner.umd.js"
1010
};
1111

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"node-ical": "^0.26.1",
101101
"nunjucks": "^3.2.4",
102102
"socket.io": "^4.8.3",
103-
"suncalc": "^1.9.0",
103+
"suncalc": "^2.0.0",
104104
"systeminformation": "^5.31.7",
105105
"undici": "^8.4.1",
106106
"weathericons": "^2.1.0"

0 commit comments

Comments
 (0)