libauth icon indicating copy to clipboard operation
libauth copied to clipboard

Issue with tree-shaking in a project using Libauth

Open paulmillr opened this issue 1 year ago • 7 comments

The library bundles libsecp256k1 and a bunch of other libraries. When one includes 10 libraries in the repository, it's not zero deps.

It's misleading to call it "zero dependencies" in README and docs.

paulmillr avatar Jun 10 '24 13:06 paulmillr

Libauth has 0 Dependencies

Screenshot 2024-06-17 at 10 09 42 AM

bitjson avatar Jun 17 '24 14:06 bitjson

The library is 4.32 megabytes. 4.32 mb of bundled libraries is not “ultra lightweight”

IMG_3143

paulmillr avatar Jun 17 '24 18:06 paulmillr

@paulmillr are you having trouble with Libauth in a particular project? Could you share an example of how you're importing or bundling Libauth?

Libauth lightweight in that it is designed to be maximally "tree shaken" by all modern build tooling, so your built project will contain only the code necessary for your application.

For example, this demo using Libauth in Vite bundles all of its code, including a Libauth function it uses (dateToLocktime) into a single 1.87kb (gzipped) JS file. Libauth contributes only ~450 bytes to this bundle. In contrast, some JS libraries prevent efficient tree shaking, so applications using only a single function might be required to import the full code of that library.

bitjson avatar Jun 19 '24 21:06 bitjson

This is not a tree shaking issue.

This is about misleading documentation. The library — all-in — is 4 megabytes. A similar "lightweight" library could be 500 kilobytes.

You're using tree-shaking? Cool. Most libraries are using tree-shaking nowadays. When all features of your library are used, it's still 4 megabytes - not 1.87kb gzipped.

The documentation can be adjusted.

paulmillr avatar Jun 19 '24 21:06 paulmillr

I'm sorry that you're so frustrated with Libauth.

It seems like you've had trouble using the Libauth in a project, but I'm afraid I'm still misunderstanding the context for your issue.

Can you explain what sort of project you're building?

What did you expect the library to do, and what happened when you tried to use it?

Are you using npm? Did installing @bitauth/libauth add other dependencies? What features of Libauth are you using? Did using Libauth increase your application's bundle size more than you expected?

If you can provide a little more detail, I'd love to help you debug the issue.

bitjson avatar Jun 20 '24 17:06 bitjson

What did you expect the library to do, and what happened when you tried to use it?

I've expected the library to be "ultra-lightweight" and "zero-dependency" but in fact it's not. It bundles other libraries such as libsecp256k1 as WASM base64. If by "zero-dependency" you've meant it's "zero NPM dependencies" it should be clarified in README.

Did installing @bitauth/libauth add other dependencies

The result size of libauth is 1.7MB. The readme claims libauth is "An ultra-lightweight JavaScript library". 1.7 MB of code is not "ultra-lightweight".

Can you explain what sort of project you're building?

I'm building libauth.

paulmillr avatar Jun 21 '24 09:06 paulmillr

Single-file libauth that weights 1.7MB

libauth.js.txt

paulmillr avatar Jun 25 '24 09:06 paulmillr