stellar / js-stellar-sdk

Main Stellar client library for the JavaScript language.
https://stellar.github.io/js-stellar-sdk/
Apache License 2.0
625 stars 306 forks source link

Can't import whold sdk module in React #931

Open acharb opened 6 months ago

acharb commented 6 months ago

Describe the bug When trying to import the entire sdk in React or React native, it returns undefined. NodeJS environment it works as expected (not sure if this is a bug or if on purpose tbh)

What version are you on? 11.2.2

To Reproduce

// React or React Native environment
import StellarSdk from "@stellar/stellar-sdk";

console.log({ StellarSdk }); // returns undefined
// NodeJS
import StellarSdk from "@stellar/stellar-sdk";

console.log({ StellarSdk }); // returns values as expected

note: for any environment importing de-structured modules works fine

Expected behavior For it to always return the same regardless of environment

Shaptic commented 6 months ago

Hmm I'm surprised this even worked on Node honestly. It should be import * as StellarSdk from ... everywhere ever since the Webpack 5 refactor.