Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit a39168b

Browse files
committed
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
1 parent cef337e commit a39168b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/core/src/main/spawn-electron.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,11 @@ export async function createWindow(
264264
}
265265

266266
if (electronRemoteNeedsInit) {
267-
// some hacks to allow @kui-shell/core to avoid specifying a
267+
// use the webpackIgnore magic comment to avoid specifying a
268268
// direct dependence on @electron/remote; this dep pulls in
269-
// all of electron, which some clients will not need
270-
const foolWebpackHack = 'index.js'
271-
require('@electron/remote/main/' + foolWebpackHack).initialize()
269+
// all of electron, which some clients will not need. if you
270+
// need it, make sure to install @electron/remote yourself.
271+
await import(/* webpackIgnore: true */ '@electron/remote/main/index.js').then(_ => _.initialize())
272272
electronRemoteNeedsInit = false
273273
}
274274

@@ -285,7 +285,10 @@ export async function createWindow(
285285
}
286286
const mainWindow = new BrowserWindow(opts) as KuiBrowserWindow
287287
if (electronRemoteIsNeeded) {
288-
require('@electron/remote/main').enable(mainWindow.webContents)
288+
// see the webpackIgnore: true comment just above
289+
await import(/* webpackIgnore: true */ '@electron/remote/main/index.js').then(_ =>
290+
_.enable(mainWindow.webContents)
291+
)
289292
}
290293
nWindows++
291294
debug('createWindow::new BrowserWindow success')

0 commit comments

Comments
 (0)