I haven't encountered a bug this gnarly in a while. 🤣
The circular import: src/wallets/mnemonic imports src/store, which imports a few types from src/wallets. The src/wallets/mnemonic is still loaded when src/store imports src/wallet despite nothing from src/wallets/mnemonic being used.
In short, src/wallets/mnemonic imports src/store, which indirectly imports src/wallets/mnemonic.
This circular import caused an odd issue where the persisted mnemonic had "undefined_mnemonic" as the key in localStorage because LOCAL_STORAGE_KEY constant (defined in src/store.ts before building the package) was used before it was defined in the dist/index.js build output file. The bundler got confused by the circular import and put the modules in the resulting dist/index.js in the wrong order.
I haven't encountered a bug this gnarly in a while. 🤣
The circular import:
src/wallets/mnemonic
importssrc/store
, which imports a few types fromsrc/wallets
. Thesrc/wallets/mnemonic
is still loaded whensrc/store
importssrc/wallet
despite nothing fromsrc/wallets/mnemonic
being used.In short,
src/wallets/mnemonic
importssrc/store
, which indirectly importssrc/wallets/mnemonic
.This circular import caused an odd issue where the persisted mnemonic had "undefined_mnemonic" as the key in localStorage because
LOCAL_STORAGE_KEY
constant (defined insrc/store.ts
before building the package) was used before it was defined in thedist/index.js
build output file. The bundler got confused by the circular import and put the modules in the resultingdist/index.js
in the wrong order.