Skip to content

refactor: simplify internal require() calls#4056

Merged
rejas merged 1 commit intoMagicMirrorOrg:developfrom
KristjanESPERANTO:refactor
Mar 12, 2026
Merged

refactor: simplify internal require() calls#4056
rejas merged 1 commit intoMagicMirrorOrg:developfrom
KristjanESPERANTO:refactor

Conversation

@KristjanESPERANTO
Copy link
Collaborator

Remove unnecessary __dirname template-literal prefix from relative require() paths. Node.js resolves relative require() paths correctly without it.

While this may look like nitpicking: require("./server") is transparent to static analysis tools - IDEs can resolve the path and support go-to-definition. Template literals with __dirname are opaque to them. It also removes another usage of __dirname, which has no native equivalent in ESM and would need to be replaced there anyway (when we switch to ESM anytime in the future).

The import reordering is a side effect: import-x/order treats template-literal require() calls differently from plain strings, so the previous order was no longer valid.

@khassel
Copy link
Collaborator

khassel commented Mar 11, 2026

test fails because of #4055 ?

Will you rebase so the tests are green before merging?

@KristjanESPERANTO
Copy link
Collaborator Author

Yes. I'll rebase tomorrow 🙂

Remove unnecessary `__dirname` template-literal prefix from
relative require() paths in js/app.js, js/server.js and js/utils.js.
Node.js resolves relative require() paths correctly without it.
@rejas rejas merged commit 21d1e74 into MagicMirrorOrg:develop Mar 12, 2026
9 checks passed
@KristjanESPERANTO KristjanESPERANTO deleted the refactor branch March 12, 2026 10:04
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.

3 participants