From a39168b327cdfc9b52dd031db090a7de4d15b61d Mon Sep 17 00:00:00 2001 From: Nick Mitchell Date: Sat, 28 Jan 2023 18:26:21 -0500 Subject: [PATCH] fix: improved fix for externalizing electron/remote - We should be using the `webpackIgnore: true` magic comment, rather than the silly hack we had from #9265 - #9265 missed the second import of electron/remote --- packages/core/src/main/spawn-electron.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/core/src/main/spawn-electron.ts b/packages/core/src/main/spawn-electron.ts index ddcf51319fb..227ee906e5a 100644 --- a/packages/core/src/main/spawn-electron.ts +++ b/packages/core/src/main/spawn-electron.ts @@ -264,11 +264,11 @@ export async function createWindow( } if (electronRemoteNeedsInit) { - // some hacks to allow @kui-shell/core to avoid specifying a + // use the webpackIgnore magic comment to avoid specifying a // direct dependence on @electron/remote; this dep pulls in - // all of electron, which some clients will not need - const foolWebpackHack = 'index.js' - require('@electron/remote/main/' + foolWebpackHack).initialize() + // all of electron, which some clients will not need. if you + // need it, make sure to install @electron/remote yourself. + await import(/* webpackIgnore: true */ '@electron/remote/main/index.js').then(_ => _.initialize()) electronRemoteNeedsInit = false } @@ -285,7 +285,10 @@ export async function createWindow( } const mainWindow = new BrowserWindow(opts) as KuiBrowserWindow if (electronRemoteIsNeeded) { - require('@electron/remote/main').enable(mainWindow.webContents) + // see the webpackIgnore: true comment just above + await import(/* webpackIgnore: true */ '@electron/remote/main/index.js').then(_ => + _.enable(mainWindow.webContents) + ) } nWindows++ debug('createWindow::new BrowserWindow success')