diff --git a/src/bootstrap.js b/src/bootstrap.js index 90054f3..e701b0d 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -48,7 +48,7 @@ const startCore = () => { }); }); - desktopCore = require('./utils/requireNative')('discord_desktop_core'); + desktopCore = require('discord_desktop_core'); desktopCore.startup({ splashScreen: splash, diff --git a/src/index.js b/src/index.js index 70328df..42b5875 100644 --- a/src/index.js +++ b/src/index.js @@ -26,9 +26,15 @@ if (process.platform === 'win32') try { for (const m of require('fs').readdirSync(b)) M.globalPaths.push(join(b, m)); // For each module dir, add to globalPaths } catch { log('Init', 'Failed to QS globalPaths') } +// inject Module.globalPaths into resolve lookups as it was removed in Electron >=17 and Discord depend on this workaround +const rlp = M._resolveLookupPaths; +M._resolveLookupPaths = (request, parent) => { + if (parent?.paths?.length > 0) parent.paths = parent.paths.concat(M.globalPaths); + return rlp(request, parent); +}; if (process.argv.includes('--overlay-host')) { // If overlay - require('./utils/requireNative')('discord_overlay2', 'standalone_host.js'); // Start overlay + require('discord_overlay2/standalone_host.js'); // Start overlay } else { require('./bootstrap')(); // Start bootstrap } \ No newline at end of file diff --git a/src/utils/requireNative.js b/src/utils/requireNative.js deleted file mode 100644 index e5832b8..0000000 --- a/src/utils/requireNative.js +++ /dev/null @@ -1,6 +0,0 @@ -// Custom requireNative as Electron >=17 breaks Module.globalPaths for some reason -// For Updater v2: get direct path in globalPaths (g[0]) -// For Module Updater: get root path for all modules in globalPaths - -const g = require('module').globalPaths.reverse(); -module.exports = (n, e = '') => require(require('path').join(g.find(x => x.includes(n)) ?? g[0], n, e)); \ No newline at end of file