在开发期间是否可以在 Electron 应用程序中使用 Elm 的调试器?

Is It Possible to Use the Elm's Debugger in an Electron App During Development?

我正在使用 Elm 0.19.1 构建桌面应用程序的界面,而该界面又基于 Electron。

但是,在Elm 的调试模式下,我无法打开调试器。这是应用 window 的控制台中显示的内容: Uncaught TypeError: Cannot set property 'title' of undefined.

由这段Elm生成的JavaScript代码触发:

var doc = debuggerWindow.document;
doc.title = 'Elm Debugger';

显然,调试器 window 对象内部没有文档 属性,这可能是因为 Electron 应用程序中的每个 window 都在自己的进程中运行.有什么方法可以解决此问题并在我的应用程序开发期间启动 Elm 的调试器和 运行?

可以通过在 BrowserWindowoptions 中将 webPreferences.nativeWindowOpen 设置为 true 来解决这个问题。这些选项记录在案 here in official Electron's documentation. This should fix the issue by letting us use Window.document as we do in the browser. This answer is totally based on bruchmann's solution in Elm's discourse.