Skip to content

refactor: rewrite Module as an ES6 class#4151

Merged
khassel merged 1 commit into
MagicMirrorOrg:developfrom
KristjanESPERANTO:esm
May 12, 2026
Merged

refactor: rewrite Module as an ES6 class#4151
khassel merged 1 commit into
MagicMirrorOrg:developfrom
KristjanESPERANTO:esm

Conversation

@KristjanESPERANTO
Copy link
Copy Markdown
Collaborator

This PR rewrites module.js to use a native ES6 class instead of Class.extend() - the same old inheritance helper that was removed from node_helper.js in #4147.

The normal module API stays the same: modules still use Module.register({...}). Internally, Module.create() now creates a named subclass for each module, copies over a cloned definition, and only calls init() when it is actually a function.

Outcome: one less file in the browser bundle, no more magic _super() wiring, better stack traces, and tests for the module creation path that did not exist before. module.js is also now a plain class with no external dependencies - an intentional step towards export default Module when browser scripts eventually move to native ES modules.

Since these changes touch the core of how modules are created, I'd appreciate a close review and any feedback on edge cases I may have missed.

Drop the old browser-side `Class.extend()` helper and make `Module`
a native class, matching the earlier `NodeHelper` rewrite.
@khassel
Copy link
Copy Markdown
Collaborator

khassel commented May 12, 2026

@KristjanESPERANTO let me know if you want to wait for other reviews, otherwise I will merge it ...

@KristjanESPERANTO
Copy link
Copy Markdown
Collaborator Author

@khassel I think one review is enough. Thanks! 🙂

@khassel khassel merged commit 79ea263 into MagicMirrorOrg:develop May 12, 2026
12 checks passed
@KristjanESPERANTO KristjanESPERANTO deleted the esm branch May 12, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants