Search code examples
javascriptnode.jstypescriptipcelectron

how to load electron module in typescript


I try to get the ipcRenderer module from electron in typescript to send informations from the current component to the core and to get informations back to the window (electron-chromium-browser). All I get is a error "Module not found" by transcoding the ts-code to ES5.

const ipc = require('electron').ipcRenderer;`

Update: The Error is switching between the "Module not found" and this one:

ERROR in ./~/electron/index.js Module build failed: Error: ENOENT, open '/.../node_modules/electron/index.js' @ ./app/components/search/search.ts 12:10-29

That is from the current electron-api. I have also tried to use the import syntax from typescript but the result is the same.

Than I tried to use the electron.ipcRenderer module in a ES5-file, loaded/linked directly in the html-file.

There it worked. Why?


Solution

  • Solved the problem after 10h searching. Problem was the webpack-transcoder.

    https://github.com/chentsulin/webpack-target-electron-renderer

    https://github.com/chentsulin/electron-react-boilerplate/blob/master/webpack.config.development.js