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
clone the boilerplate repository
install native package @truffle/hdwallet-provider in release/app with
$npm install @truffle/hdwallet-provider
create a provider with a http url and a private key on a function that is loaded at the begining.
create the binary using
$ npm run package
run the binary
to create a provider on the third step I created an account in mumbai test net. With it, import the dependency on the src/main/preload.ts file
import HDWalletProvider from '@truffle/hdwallet-provider';
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' });
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
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
Expected Behavior
binary runs fine without errors
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
to create a provider on the third step I created an account in mumbai test net. With it, import the dependency on the src/main/preload.ts file
import HDWalletProvider from '@truffle/hdwallet-provider'
;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
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:
/home/electron-react-boilerplate-main/release/build/linux-unpacked/resources/app.asar/node_modules/@truffle/hdwallet-provider/dist/index.js
/home/electron/electron-react-boilerplate-main/release/build/linux-unpacked/resources/app.asar/dist/main/preload.js
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