Motivation
If one is using bip39 in a front-end web application (as is Paratii-Portal), there is a strong desire to only import the absolute minimum code needed to keep our application bundle size as small as possible. Given how the code in bip39 is currently organized, one cannot import/require individual functions from the module w/o importing the entirety of the module (including its dependencies). Some dependencies (specifically unorm and the language files) are quite large and are not required for every single function in this package.
Selfishly speaking, this change enables the size of our imports from bip39 to decrease by 90KB
Work Done
move all source code into /src
do not define any functions in /src/index.js. Instead, Define them individually in their own modules and then have /src/index.js import them. The existing api for importing code from this package has not changed, but now it is possible import just src/generateMnemonic.js, for example.
Issue bip39#81
Motivation If one is using bip39 in a front-end web application (as is Paratii-Portal), there is a strong desire to only import the absolute minimum code needed to keep our application bundle size as small as possible. Given how the code in
bip39
is currently organized, one cannotimport/require
individual functions from the module w/o importing the entirety of the module (including its dependencies). Some dependencies (specificallyunorm
and the language files) are quite large and are not required for every single function in this package.Selfishly speaking, this change enables the size of our imports from
bip39
to decrease by90KB
Work Done
/src
/src/index.js
. Instead, Define them individually in their own modules and then have/src/index.js
import them. The existing api for importing code from this package has not changed, but now it is possible import justsrc/generateMnemonic.js
, for example.