okikio / bundlejs

An online tool to quickly bundle & minify your projects, while viewing the compressed gzip/brotli bundle size, all running locally on your browser.
https://bundlejs.com
MIT License
797 stars 15 forks source link

Size reported of bundle is off #47

Closed allain closed 1 year ago

allain commented 1 year ago

It's reporting the following code bundles to a couple hundred bytes but it is closer to 10k or so.

export {observer,computed, dispose} from "hyperactiv";

Reports: Bundle size is 174B -> 119B (gzip)

When I enable analisys treemap, I can see that it's able to see the code defined though.

okikio commented 1 year ago

Sorry for the late response. hyperactiv only has a default export, so it's not able destructure properly when exporting

image

The solution is to import the default export from hyperactiv first, then export the methods you'd like treeshaken

import hyperactiv from 'hyperactiv'
export const { observe, computed } = hyperactiv

https://bundlejs.com/?q=(import)hyperactiv&treeshake=[hyperactiv]&text="export+const+{observe,computed}+=+hyperactiv"

allain commented 1 year ago

My apologies. I'd read and then forgot about it.

Thanks for replying

okikio commented 1 year ago

No worries 👍