consento-org / consento-org/longfn

Improve tree shaking?

Open
#4 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Hi there,

I was interested in using longfn to reduce bundle size a little bit compared with long.. I thought the 'pure function' way that longfn works might lend itself to tree shaking but the bundle was maybe not 'tree shaken'.

I probably obsess over bundle size too much but it is including the entirety of longfn (6kb minified) instead of just the functions imported. (for comparison long.js ~10kb minified)

A production build using vite with just longfn imported can show this

![image](https://github.com/user-attachments/assets/86479b5f-af9a-4e87-841c-0b067cac8fdc)

Screenshot above made using "yarn build" in the repro, then running server in dist, and running "npx bundle-wizard http://localhost:3000"...of course react the major culprit in bundle there

Repo here, very minimal https://github.com/cmdcolin/longfn-tree-shake-repro/blob/master/src/App.tsx

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.