Skip to content

refactor: rewrite NodeHelper as an ES6 class#4147

Merged
khassel merged 1 commit intoMagicMirrorOrg:developfrom
KristjanESPERANTO:nodehelper-class
May 8, 2026
Merged

refactor: rewrite NodeHelper as an ES6 class#4147
khassel merged 1 commit intoMagicMirrorOrg:developfrom
KristjanESPERANTO:nodehelper-class

Conversation

@KristjanESPERANTO
Copy link
Copy Markdown
Collaborator

@KristjanESPERANTO KristjanESPERANTO commented May 7, 2026

This PR rewrites node_helper.js to use a native ES6 class instead of Class.extend() - a manual inheritance helper from 2008, written back when class syntax didn't exist yet. Node.js has supported native classes since v6, so there's no reason to keep the workaround around.

The public API is unchanged - module authors still write the same NodeHelper.create({...}) they always have.

Outcome: same behavior, normal modern JavaScript, better stack traces, and node_helper.js no longer pulls in class.js on the server side. Removing class.js altogether is a follow-up (it's still used on browser side).

Replaces the legacy Class.extend() inheritance pattern with a native ES6
class. NodeHelper.create() remains the public API and is fully compatible
with all third-party modules.
@KristjanESPERANTO
Copy link
Copy Markdown
Collaborator Author

The failed Node 26 test seems unrelated to the changes to me. It hangs at the MM installation step; at that point, the modified code is irrelevant.

@khassel
Copy link
Copy Markdown
Collaborator

khassel commented May 8, 2026

The failed Node 26 test seems unrelated to the changes to me. It hangs at the MM installation step; at that point, the modified code is irrelevant.

yes, tested it on my fork without this PR and same result, maybe introduced with node v26.1.0, will try to test this locally later ...

@khassel khassel merged commit 67db41c into MagicMirrorOrg:develop May 8, 2026
20 of 24 checks passed
@khassel
Copy link
Copy Markdown
Collaborator

khassel commented May 8, 2026

I found that the line npx playwright install chromium is the problem, there is already an issue in the playwright repo, see microsoft/playwright#40724

@KristjanESPERANTO
Copy link
Copy Markdown
Collaborator Author

Great find!

@KristjanESPERANTO KristjanESPERANTO deleted the nodehelper-class branch May 8, 2026 18:10
KristjanESPERANTO added a commit to KristjanESPERANTO/MagicMirror that referenced this pull request May 8, 2026
`module.js` still used `Class.extend()`, the same old inheritance helper
removed from `node_helper.js` in MagicMirrorOrg#4147. This finishes the cleanup on
the browser side.

`Module.create()` now follows the same pattern as `NodeHelper.create()`:
`Object.assign(this, definition)` in the subclass constructor, `init()`
called explicitly. `cloneObject()` moves into `module.js` where it belongs,
the `<script>` tag for `class.js` is gone from `index.html`, and newsfeed's
`this._super()` becomes `Module.prototype.getDom.call(this)`.

Result: one fewer file in the browser bundle, no more magic `_super`
wiring, and `module.js` is easier to read without knowing how
`Class.extend()` worked.
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