sindresorhus/electron-timber

electron-builder redistributables can't find preload.js

Opened this issue · 3 comments

I noticed that my electron program fails to start because it can't find preload.js. Looking at the webpack-compiled bundle, I found that the culprit must be electron-timber, since it's the only module that looks for preview.js. Here's the output:

[26945:0728/234248.108082:ERROR:CONSOLE(164)] "Unable to load preload script: /home//projects/electron/nuclear/release/linux-unpacked/resources/app.asar/dist/preload.js", source: /home//projects/electron/nuclear/release/linux-unpacked/resources/electron.asar/renderer/init.js (164)
[26945:0728/234248.108149:ERROR:CONSOLE(165)] "Error: Cannot find module '/home//projects/electron/nuclear/release/linux-unpacked/resources/app.asar/dist/preload.js'
    at Module._resolveFilename (module.js:543:15)
    at Function.Module._resolveFilename (/home//projects/electron/nuclear/release/linux-unpacked/resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:473:25)
    at Module.require (module.js:586:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home//projects/electron/nuclear/release/linux-unpacked/resources/electron.asar/renderer/init.js:162:5)
    at Object.<anonymous> (/home//projects/electron/nuclear/release/linux-unpacked/resources/electron.asar/renderer/init.js:188:3)
    at Module._compile (module.js:642:30)
    at Object.Module._extensions..js (module.js:653:10)
    at Module.load (module.js:561:32)", source: /home//projects/electron/nuclear/release/linux-unpacked/resources/electron.asar/renderer/init.js (165)

It loads fine in debug build. What prevents it from running in production build?

You have to exclude the preload.js script in this package from being compiled with Webpack.

I've opened an Electron feature request to make this just work: electron/electron#14012

Adding exclude: /node_modules\/electron\-timber\/preload\.js/ to the jsx parsing rule in webpack did the trick, thanks for the help.