Skip to content

Commit 8cf5233

Browse files
committed
rewrite: replace requireNative with globalPaths workaround
Added Module.globalPaths workaround (reintroduce native usage instead of our own util using it) is needed as Discord's overlay code depends on their own implementation of this. Also removed requireNative and replace with just require since no longer needed with this hack anyway.
1 parent d8035e1 commit 8cf5233

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/bootstrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const startCore = () => {
4848
});
4949
});
5050

51-
desktopCore = require('./utils/requireNative')('discord_desktop_core');
51+
desktopCore = require('discord_desktop_core');
5252

5353
desktopCore.startup({
5454
splashScreen: splash,

src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ if (process.platform === 'win32') try {
2626
for (const m of require('fs').readdirSync(b)) M.globalPaths.push(join(b, m)); // For each module dir, add to globalPaths
2727
} catch { log('Init', 'Failed to QS globalPaths') }
2828

29+
// inject Module.globalPaths into resolve lookups as it was removed in Electron >=17 and Discord depend on this workaround
30+
const rlp = M._resolveLookupPaths;
31+
M._resolveLookupPaths = (request, parent) => {
32+
if (parent?.paths?.length > 0) parent.paths = parent.paths.concat(M.globalPaths);
33+
return rlp(request, parent);
34+
};
2935

3036
if (process.argv.includes('--overlay-host')) { // If overlay
31-
require('./utils/requireNative')('discord_overlay2', 'standalone_host.js'); // Start overlay
37+
require('discord_overlay2/standalone_host.js'); // Start overlay
3238
} else {
3339
require('./bootstrap')(); // Start bootstrap
3440
}

src/utils/requireNative.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)