Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remote in ElectronService is undefined when using AWS Amplify #609

Closed
GageSorrell opened this issue May 24, 2021 · 1 comment
Closed

remote in ElectronService is undefined when using AWS Amplify #609

GageSorrell opened this issue May 24, 2021 · 1 comment

Comments

@GageSorrell
Copy link

Describe the bug
Making any call to the remote object fails. Running console.log(remote) returns undefined.

To Reproduce
Steps to reproduce the behavior:

  1. Clone the repo.
  2. Install and set up AWS Amplify.
  3. In the ElectronService, add a call to the remote object. For example, this.remote.BrowserWindow.getFocusedWindow().minimize();

Expected behavior
remote should be defined, and the minimize() example above should minimize the window.

@GageSorrell
Copy link
Author

GageSorrell commented May 24, 2021

Solution

While setting up AWS Amplify, you are required to add this polyfill:

__polyfills.ts__
(window as any).global = window;
(window as any).process = {
    env: { DEBUG: undefined },
};

This interferes with the getter isElectron in ElectronService. isElectron is used to determine whether to perform the Electron imports, including remote. If your project is intended to only run in Electron, you may remove the isElectron check for the Electron imports:

__electron.service.ts__
constructor() {
    this.ipcRenderer = window.require('electron').ipcRenderer;
    ...
    this.remote = window.require('electron').remote;
    ...
}

You may also need to replace window.require('electron').remote with window.require('@electron/remote').

May this post save you the time and headache that it caused me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant