bitcoinjs / bolt11

A library for encoding and decoding lightning network payment requests as defined in BOLT #11.
MIT License
92 stars 64 forks source link

Make modules tree-shakeable #17

Open wbobeirne opened 5 years ago

wbobeirne commented 5 years ago

I haven't done extensive testing on this, so I may be wrong, but the way this package is currently set up isn't tree-shakeable by compilers that have that capability. This could be done by splitting files up and only importing what each export needs. The way I imagine this working is having an encode.js and a decode.js and having them import only the utility functions they need. The main file would simply be an export of those two (along with the other utility functions currently exported.)

This would also allow people who don't have tree shaking setup to import specific exports, like so:

import decode from 'bolt11/decode';

More info about Webpack's approach to tree shaking here: https://webpack.js.org/guides/tree-shaking/

junderw commented 5 years ago

Pull Requests are welcome!