Skip to content

Commit

Permalink
fix: improved fix for externalizing electron/remote
Browse files Browse the repository at this point in the history
- We should be using the `webpackIgnore: true` magic comment, rather than the silly hack we had from kubernetes-sigs#9265
- kubernetes-sigs#9265 missed the second import of electron/remote
  • Loading branch information
starpit committed Jan 28, 2023
1 parent cef337e commit a39168b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/core/src/main/spawn-electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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')
Expand Down

0 comments on commit a39168b

Please sign in to comment.