Compare commits

...

3 Commits

Author SHA1 Message Date
Kristjan ESPERANTO
787cc6bd1f refactor: replace module-alias dependency with internal alias resolver (#3893)
- removes the external unmaintained `module-alias` dependency ->
reducing complexity and risk
- introduces a small internal alias mechanism for `logger` and
`node_helper`
- preserves backward compatibility for existing 3rd‑party modules
- should simplify a future ESM migration of MagicMirror

I'm confident that it shouldn't cause any problems, but we could also
consider including it in the release after next. What do you think?

This PR is inspired by PR #2934 - so thanks to @thesebas! 🙇 😃
2025-09-30 20:12:58 +02:00
Kristjan ESPERANTO
b1a189b238 Prepare 2.34.0-develop 2025-09-30 18:14:08 +02:00
Kristjan ESPERANTO
593a4b95d6 Prepare Release 2.33.0 (#3902) 2025-09-30 16:15:50 +02:00
12 changed files with 74 additions and 33 deletions

View File

@@ -7,11 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
❤️ **Donate:** Enjoying MagicMirror²? [Please consider a donation!](https://magicmirror.builders/#donate) With your help we can continue to improve the MagicMirror².
## [2.33.0] - unreleased
## [2.34.0] - unreleased
planned for 2025-10-01
planned for 2026-01-01
Thanks to: @dathbe.
### Added
### Changed
- [core] refactor: replace `module-alias` dependency with internal alias resolver (#3893)
### Fixed
### Updated
## [2.33.0] - 2025-10-01
Thanks to: @Crazylegstoo, @dathbe, @m-idler, @plebcity, @khassel, @KristjanESPERANTO, @rejas and @sdetweil!
> ⚠️ This release needs nodejs version `v22.18.0 or higher`
@@ -60,7 +72,7 @@ Thanks to: @dathbe.
- [core] Fixed socket.io timeout when server is slow to send notification, notification lost at client (#3380)
- [tests] refactor AnimateCSS tests after jsdom 27 upgrade (#3891)
- [weather] Use `apparent_temperature` data from openmeteo's hourly weather for current feelsLikeTemp (#3868).
- [weather] Updated envcanada Provider to use new database/URL schema for accessing weather data (#3822).
- [weather] Updated envcanada Provider to use new database/URL schema for accessing weather data (#3878).
## [2.32.0] - 2025-07-01
@@ -1826,7 +1838,8 @@ It includes (but is not limited to) the following features:
This was part of the blogpost: [https://michaelteeuw.nl/post/83916869600/magic-mirror-part-vi-production-of-the](https://michaelteeuw.nl/post/83916869600/magic-mirror-part-vi-production-of-the)
[2.33.0]: https://github.com/MagicMirrorOrg/MagicMirror/compare/v2.32.0...develop
[2.34.0]: https://github.com/MagicMirrorOrg/MagicMirror/compare/v2.33.0...develop
[2.33.0]: https://github.com/MagicMirrorOrg/MagicMirror/compare/v2.32.0...v2.33.0
[2.32.0]: https://github.com/MagicMirrorOrg/MagicMirror/compare/v2.31.0...v2.32.0
[2.31.0]: https://github.com/MagicMirrorOrg/MagicMirror/compare/v2.30.0...v2.31.0
[2.30.0]: https://github.com/MagicMirrorOrg/MagicMirror/compare/v2.29.0...v2.30.0

View File

@@ -22,6 +22,7 @@ Are done by
- [ ] @rejas
- [ ] @sdetweil
- [ ] @khassel
- [ ] @KristjanESPERANTO
### Pre-Deployment steps

View File

@@ -1,6 +1,6 @@
# The MIT License (MIT)
Copyright © 2016-2025 Michael Teeuw
Copyright © 2016-2026 Michael Teeuw
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View File

@@ -21,6 +21,7 @@
"browserwindow",
"bryanzzhu",
"btoconnor",
"bughaver",
"bugsounet",
"buxxi",
"byday",
@@ -44,6 +45,7 @@
"darksky",
"dateheader",
"dateheaders",
"dathbe",
"davide",
"DAYAFTERTOMORROW",
"DAYBEFOREYESTERDAY",
@@ -175,6 +177,7 @@
"oraclesean",
"oscarb",
"philnagel",
"plebcity",
"Português",
"PRECIP",
"Problema",
@@ -233,6 +236,7 @@
"Weatherflow",
"weatherforecast",
"weathergov",
"weathericon",
"weathericons",
"weatherobject",
"weatherutils",

View File

@@ -1,3 +1,7 @@
const aliasMapper = {
logger: "<rootDir>/js/logger.js"
};
const config = {
verbose: true,
testTimeout: 20000,
@@ -6,21 +10,21 @@ const config = {
{
displayName: "unit",
globalSetup: "<rootDir>/tests/unit/helpers/global-setup.js",
moduleNameMapper: {
logger: "<rootDir>/js/logger.js"
},
moduleNameMapper: aliasMapper,
testMatch: ["**/tests/unit/**/*.[jt]s?(x)"],
testPathIgnorePatterns: ["<rootDir>/tests/unit/mocks", "<rootDir>/tests/unit/helpers"]
},
{
displayName: "electron",
testMatch: ["**/tests/electron/**/*.[jt]s?(x)"],
moduleNameMapper: aliasMapper,
testPathIgnorePatterns: ["<rootDir>/tests/electron/helpers"]
},
{
displayName: "e2e",
testMatch: ["**/tests/e2e/**/*.[jt]s?(x)"],
modulePaths: ["<rootDir>/js/"],
moduleNameMapper: aliasMapper,
testPathIgnorePatterns: ["<rootDir>/tests/e2e/helpers", "<rootDir>/tests/e2e/mocks"]
}
],

31
js/alias-resolver.js Normal file
View File

@@ -0,0 +1,31 @@
// Internal alias mapping for default and 3rd party modules.
// Provides short require identifiers: "logger" and "node_helper".
// For a future ESM migration, replace this with a public export/import surface.
const path = require("node:path");
const Module = require("module");
const root = path.join(__dirname, "..");
// Keep this list minimal; do not add new aliases without architectural review.
const ALIASES = {
logger: "js/logger.js",
node_helper: "js/node_helper.js"
};
// Resolve to absolute paths now.
const resolved = Object.fromEntries(
Object.entries(ALIASES).map(([k, rel]) => [k, path.join(root, rel)])
);
// Prevent multiple patching if this file is required more than once.
if (!Module._mmAliasPatched) {
const origResolveFilename = Module._resolveFilename;
Module._resolveFilename = function (request, parent, isMain, options) {
if (Object.prototype.hasOwnProperty.call(resolved, request)) {
return resolved[request];
}
return origResolveFilename.call(this, request, parent, isMain, options);
};
Module._mmAliasPatched = true; // non-enumerable marker would be overkill here
}

View File

@@ -1,5 +1,5 @@
// Alias modules mentioned in package.js under _moduleAliases.
require("module-alias/register");
// Load lightweight internal alias resolver
require("./alias-resolver");
const fs = require("node:fs");
const path = require("node:path");

View File

@@ -1,12 +1,15 @@
// Ensure internal require aliases (e.g., "logger") resolve when this file is run as a standalone script
require("./alias-resolver");
const path = require("node:path");
const fs = require("node:fs");
const { styleText } = require("node:util");
const Ajv = require("ajv");
const globals = require("globals");
const { Linter } = require("eslint");
const Log = require("logger");
const rootPath = path.resolve(`${__dirname}/../`);
const Log = require(`${rootPath}/js/logger.js`);
const Utils = require(`${rootPath}/js/utils.js`);
const linter = new Linter({ configType: "flat" });

View File

@@ -1,10 +1,7 @@
const path = require("node:path");
const rootPath = path.resolve(`${__dirname}/../`);
const Log = require(`${rootPath}/js/logger.js`);
const os = require("node:os");
const fs = require("node:fs");
const si = require("systeminformation");
const Log = require("logger");
const modulePositions = []; // will get list from index.html
const regionRegEx = /"region ([^"]*)/i;

View File

@@ -3,8 +3,8 @@
* use this script with `node debug.js` to test the fetcher without the need
* of starting the MagicMirror² core. Adjust the values below to your desire.
*/
// Alias modules mentioned in package.js under _moduleAliases.
require("module-alias/register");
// Load internal alias resolver
require("../../../js/alias-resolver");
const Log = require("logger");
const CalendarFetcher = require("./calendarfetcher");

11
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "magicmirror",
"version": "2.33.0-develop",
"version": "2.34.0-develop",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "magicmirror",
"version": "2.33.0-develop",
"version": "2.34.0-develop",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
@@ -25,7 +25,6 @@
"helmet": "^8.1.0",
"html-to-text": "^9.0.5",
"iconv-lite": "^0.7.0",
"module-alias": "^2.2.3",
"moment": "^2.30.1",
"moment-timezone": "^0.6.0",
"node-ical": "^0.21.0",
@@ -10448,12 +10447,6 @@
"node": ">=10"
}
},
"node_modules/module-alias": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/module-alias/-/module-alias-2.2.3.tgz",
"integrity": "sha512-23g5BFj4zdQL/b6tor7Ji+QY4pEfNH784BMslY9Qb0UnJWRAt+lQGLYmRaM0KDBwIG23ffEBELhZDP2rhi9f/Q==",
"license": "MIT"
},
"node_modules/module-details-from-path": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/module-details-from-path/-/module-details-from-path-1.0.4.tgz",

View File

@@ -1,6 +1,6 @@
{
"name": "magicmirror",
"version": "2.33.0-develop",
"version": "2.34.0-develop",
"description": "The open source modular smart mirror platform.",
"keywords": [
"magic mirror",
@@ -84,7 +84,6 @@
"helmet": "^8.1.0",
"html-to-text": "^9.0.5",
"iconv-lite": "^0.7.0",
"module-alias": "^2.2.3",
"moment": "^2.30.1",
"moment-timezone": "^0.6.0",
"node-ical": "^0.21.0",
@@ -121,9 +120,5 @@
},
"engines": {
"node": ">=22.18.0"
},
"_moduleAliases": {
"node_helper": "js/node_helper.js",
"logger": "js/logger.js"
}
}