sindresorhus / electron-debug

Adds useful debug features to your Electron app
MIT License
750 stars 49 forks source link

Different require in webContents throws blocks loading right click context #13

Closed mariokostelac closed 9 years ago

mariokostelac commented 9 years ago

If Ember app is wrapped in Electron, original module and require globals have to be replaced with ember versions of that. That blocks loading right click context on https://github.com/sindresorhus/electron-debug/blob/master/index.js#L25. Could we make require call configurable?

sindresorhus commented 9 years ago

Configurable how? I would strongly prefer a workaround that doesn't introduce configuration.

mariokostelac commented 9 years ago

I was thinking something like

webContents.executeJavaScript(`${settings.require_fn}('${__dirname}/context-menu').install();`);

having settings.require_fn set to 'require' by default.

parro-it commented 9 years ago

I think browser-window-created app event is called before user get any change to load an url on the browser window instance. The event receive the browser window instance as an argument. We could use this event to save original value of require and than use that to load the context-menu module.

This way no configuration is needed at all, and user code on page could do wehatever it want to window.require. I could prepare a PR for this.

sindresorhus commented 9 years ago

:+1:

mariokostelac commented 9 years ago

@parro-it would you create a PR for that or you want me to do that?

parro-it commented 9 years ago

@mariokostelac I will, thank you.