electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.64k stars 1.74k forks source link

code not includes @truffle/hdwallet-provider dependency in built #6833

Closed israel-gonzalezmedina closed 2 years ago

israel-gonzalezmedina commented 2 years ago

Current Behavior

the @truffle/hdwallet-provider dependency is not loaded in the binary so the call inside the code returns an error

when running binary the call of the hd provider object gives an error

Steps to Reproduce

** I reproduce the error with minimal changes to the original template

and add the following lines inside function "once" on src/main/preload.ts let provider = new HDWalletProvider({ privateKeys: ['0x65eac84ea2b63f6844cd179b70d8edeab6490d399220c932304dcee620e4feb5'], providerOrUrl: 'https://rpc-mumbai.maticvigil.com/v1/e0052982a1645cd014792bf58692c3f65c663f70' });

stack traces

  1. VM113 renderer_init:73 Unable to load preload script: /home//electron-react-boilerplate-main/release/build/linux-unpacked/resources/app.asar/dist/main/preload.js VM113 renderer_init:73 Error: Cannot find module './constructor/getOptions' Require stack:

  2. /home/electron-react-boilerplate-main/release/build/linux-unpacked/resources/app.asar/node_modules/@truffle/hdwallet-provider/dist/index.js

  3. /home/electron/electron-react-boilerplate-main/release/build/linux-unpacked/resources/app.asar/dist/main/preload.js

  4. at Module._resolveFilename (VM94 loader:940:15) at Function.i._resolveFilename (VM113 renderer_init:33:1095) at Module._load (VM94 loader:785:27) at Function.c._load (VM110 asar_bundle:5:13343) at Function.i._load (VM113 renderer_init:33:356) at Module.require (VM94 loader:1012:19) at require (VM93 helpers:102:18) at Object. (index.ts:32:1) at Object. (index.ts:396:27) at Module._compile (VM94 loader:1116:14) renderer.js:2 Uncaught TypeError: Cannot read properties of undefined (reading 'ipcRenderer') at Object.822 (renderer.js:2:158528) at n (renderer.js:2:158774) at renderer.js:2:159151 at renderer.js:2:159159 at renderer.js:2:158 at renderer.js:2:223

Possible Solution (Not obligatory)

I look on the web and it seems there is a possible bug with electron builder related to the package directory name constructor https://stackoverflow.com/questions/70901907/electron-builder-not-including-entire-dependency-in-built-version the accepted solution proposes a change in the installed package that really works however, not a good solution. There are others suggestions referring to configuration

mmaietta commented 2 years ago

I recall doing that investigation. asar package seems to not consider anything named "constructor" to be valid. AFAIK, the minimal-entry route is to use asarUnpack to circumvent the issue