From 76f4a439f8cc069091a3da788f5bce2da71cefeb Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Tue, 28 Jul 2026 09:11:29 +0200 Subject: [PATCH 1/6] refactor: use explicit module import in main.js --- index.html | 1 - js/main.js | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index dba2552069..087405e558 100644 --- a/index.html +++ b/index.html @@ -52,7 +52,6 @@ - diff --git a/js/main.js b/js/main.js index a13e11b41c..92d966bc79 100644 --- a/js/main.js +++ b/js/main.js @@ -1,5 +1,8 @@ /* global addAnimateCSS, removeAnimateCSS, AnimateCSSIn, AnimateCSSOut, modulePositions, io */ +// Ensure Module global bridge is initialized before main bootstrap logic runs. +// eslint-disable-next-line import-x/extensions +import "./module.js"; // eslint-disable-next-line import-x/extensions import { loadModules } from "./loader.js"; // eslint-disable-next-line import-x/extensions From 77979ead05d37c9b733ec508ccfc7cb1a296da6f Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Tue, 28 Jul 2026 09:11:30 +0200 Subject: [PATCH 2/6] refactor: use explicit globalThis in socketclient --- js/socketclient.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/js/socketclient.js b/js/socketclient.js index 9a2dfbfd98..bf793c9698 100644 --- a/js/socketclient.js +++ b/js/socketclient.js @@ -1,18 +1,18 @@ -/* global io */ - export const MMSocket = function (moduleName) { if (typeof moduleName !== "string") { throw new Error("Please set the module name for the MMSocket."); } + const ioClient = globalThis.io; + if (typeof ioClient !== "function") { + throw new Error("socket.io client is not available."); + } + this.moduleName = moduleName; // Private Methods - let base = "/"; - if (typeof config !== "undefined" && typeof config.basePath !== "undefined") { - base = config.basePath; - } - this.socket = io(`/${this.moduleName}`, { + const base = globalThis.config?.basePath ?? "/"; + this.socket = ioClient(`/${this.moduleName}`, { path: `${base}socket.io`, pingInterval: 120000, // send pings every 2 mins pingTimeout: 120000 // wait up to 2 mins for a pong From ab626c5ff796563b8ef20c9dff9e8a39189467ef Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Tue, 28 Jul 2026 09:11:30 +0200 Subject: [PATCH 3/6] refactor: use globalThis.nunjucks in module --- js/module.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/module.js b/js/module.js index 9f4d0d8520..8bf1b719e5 100644 --- a/js/module.js +++ b/js/module.js @@ -1,5 +1,3 @@ -/* global nunjucks */ - // eslint-disable-next-line import-x/extensions import { loadFileForModule } from "./loader.js"; // eslint-disable-next-line import-x/extensions @@ -166,13 +164,15 @@ export class Module { return this._nunjucksEnvironment; } - this._nunjucksEnvironment = new nunjucks.Environment(new nunjucks.WebLoader(this.file(""), { async: true }), { + const nunjucksEngine = globalThis.nunjucks; + + this._nunjucksEnvironment = new nunjucksEngine.Environment(new nunjucksEngine.WebLoader(this.file(""), { async: true }), { trimBlocks: true, lstripBlocks: true }); this._nunjucksEnvironment.addFilter("translate", (str, variables) => { - return nunjucks.runtime.markSafe(this.translate(str, variables)); + return nunjucksEngine.runtime.markSafe(this.translate(str, variables)); }); return this._nunjucksEnvironment; From acb9b39db29a9e843f899f1ec191f7722b9a6146 Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Tue, 28 Jul 2026 09:11:31 +0200 Subject: [PATCH 4/6] refactor: use globalThis for io --- js/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/main.js b/js/main.js index 92d966bc79..59788020fe 100644 --- a/js/main.js +++ b/js/main.js @@ -1,4 +1,4 @@ -/* global addAnimateCSS, removeAnimateCSS, AnimateCSSIn, AnimateCSSOut, modulePositions, io */ +/* global addAnimateCSS, removeAnimateCSS, AnimateCSSIn, AnimateCSSOut, modulePositions */ // Ensure Module global bridge is initialized before main bootstrap logic runs. // eslint-disable-next-line import-x/extensions @@ -596,8 +596,9 @@ export const MM = { createDomObjects(); // Setup global socket listener for RELOAD event (watch mode) - if (typeof io !== "undefined") { - const socket = io("/", { + const ioClient = globalThis.io; + if (typeof ioClient !== "undefined") { + const socket = ioClient("/", { path: `${config.basePath || "/"}socket.io` }); From 7f9970eb9fd84202e2ea8049d12cfa8d39527885 Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Tue, 28 Jul 2026 09:11:31 +0200 Subject: [PATCH 5/6] lint: scope import extensions rule to ESM core files --- eslint.config.mjs | 13 +++++++++++++ js/main.js | 3 --- js/module.js | 3 --- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index f4bac84ec2..921be57464 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -99,6 +99,19 @@ export default defineConfig([ "sort-keys": "off" } }, + { + files: [ + "js/main.js", + "js/module.js", + "js/loader.js", + "js/socketclient.js", + "js/translator.js" + ], + rules: { + // Browser ESM entry files must always include the file extension in relative imports. + "import-x/extensions": ["error", "always"] + } + }, { files: ["**/*.js"], ignores: [ diff --git a/js/main.js b/js/main.js index 59788020fe..a9ab5b8382 100644 --- a/js/main.js +++ b/js/main.js @@ -1,11 +1,8 @@ /* global addAnimateCSS, removeAnimateCSS, AnimateCSSIn, AnimateCSSOut, modulePositions */ // Ensure Module global bridge is initialized before main bootstrap logic runs. -// eslint-disable-next-line import-x/extensions import "./module.js"; -// eslint-disable-next-line import-x/extensions import { loadModules } from "./loader.js"; -// eslint-disable-next-line import-x/extensions import { Translator } from "./translator.js"; let modules = []; diff --git a/js/module.js b/js/module.js index 8bf1b719e5..8ce48b2b84 100644 --- a/js/module.js +++ b/js/module.js @@ -1,8 +1,5 @@ -// eslint-disable-next-line import-x/extensions import { loadFileForModule } from "./loader.js"; -// eslint-disable-next-line import-x/extensions import { MMSocket } from "./socketclient.js"; -// eslint-disable-next-line import-x/extensions import { Translator } from "./translator.js"; /* From 4f6052365e3c54e027e3f1c4158ca2017f55bfeb Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Tue, 28 Jul 2026 09:40:05 +0200 Subject: [PATCH 6/6] refactor: remove no longer needed defaults script --- index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/index.html b/index.html index 087405e558..806fcc34f7 100644 --- a/index.html +++ b/index.html @@ -43,7 +43,6 @@
-