Open rdickert opened 8 years ago
I understand my problem now. This error occurred because I was trying to test my Electron app against a production site without deploying the new codebase. To answer my own question, the ElectronImplementation
object is from app/preload.js
. This file is passed in the options when we call new BrowserWindow(windowOptions)
and causes that file to be run locally by Electron - it will always be present. The Electron
object is created in client/index.js
, which is run in the normal Meteor app (it is extended with ElectronImplementation
, giving you access to any properties defined there, including any part of the Node API you have exposed). You can run the dev version of your app pointed at a production server and it won't throw an error, but if you haven't deployed your codebase, client/index.js
will not be present, so you won't have access to the Electron object (nor will any of your app-based code be there to use it). This is pretty obvious in hindsight, but since it threw me, I thought I'd document it here.
There may still be a documentation issue here. Should the Electron app warn you when you are running in a place where the Electron
object is not available ("Electron object not available. Are you running a development app against a server that doesn't have the meteor-electron package installed")? Such a warning (perhaps in the console) would have helped me to realize my error faster.
I like that idea @rdickert. Where do you envision we would log that? I would envision logging it from client code—but it seems you're talking about a case where we can't load client code.
There's still preload.js. We might be able to check from there as I believe it does not depend on the server. Since it loads before any other client code, we probably have to make sure other code has a chance to load, but that seems possible.
To reproduce:
meteor create
an app, build for Windows, and run it in Windows. Open the dev tools with xtrl-shift-I. Open the console with esc. In the console, Begin typing "Electron". You will see thatElectronImplementation
is present, butElectron
is not. Compare to osx where both objects are present.It's not clear to me why
ElectronImplementation
exists. It seems to have the same methods as Electron. In this case, it leads to a simple workaround in the app code:But it would be nice to have the
Electron
object turn up properly on both platforms (and perhaps removeElectronImplementation
).