Closed sukhbirsingh1512 closed 1 year ago
https://github.com/vechain/connex/tree/master/packages/connex#using-in-nodejs-environment
I'm not able to import this lib into client Node code with ssr enabled. If possible, would be nice to add a shim so if the browser object is not defined than no error would be thrown immediately. The workaround is to conditionally/dynamically import the library, but that is not always possible, and seems like ideally the entry point would evaluate whether the required object even exists (and if it does not, nothing should be ran)
My code
import Connex from '@vechain/connex'
const connex = new Connex({ node: 'https://testnet.veblocks.net/', network: 'test' })
======Response======= eracomtechnologies@Eracoms-MacBook-Pro c9x % node index.mjs /Users/eracomtechnologies/Eracom/node_modules/@vechain/connex/dist/connex.js:10 })(self, function() { ^
ReferenceError: self is not defined at Object. (/Users/eracomtechnologies/Eracom/node_modules/@vechain/connex/dist/connex.js:10:4)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap. (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)