thegreenwebfoundation / co2.js

An npm module for accessing the green web API, and estimating the carbon emissions from using digital services
Other
385 stars 48 forks source link

Move debug to devDependencies #122

Closed fershad closed 1 year ago

fershad commented 1 year ago

Currently the debug package is shipped as a project dependency. It looks as though it is being used to sanity check results in from the hosting checks.

Could these be moved out to another file, a test, or put behind a flag? In that way, we can move debug into devDependencies and reduce the package size for this library.

mrchrisadams commented 1 year ago

Does it reduce the size by much ?

I was under the impression that debug was quite a small library, and being able to switch on debugging turns out to be quite helpful.

To be fair it we might not need as much as before - if we having some newer updated tests might make it easier to let of it.

fershad commented 1 year ago

It currently accounts for ~30% of our minified bundle size. https://bundlephobia.com/package/@tgwf/co2@0.11.3

tackaberry commented 1 year ago

hey @mrchrisadams and @fershad.

It seems debug really isn't used. Removing entirely seems to have no functional effect but has a 30k impact on the IIFE/Browser build.

https://github.com/thegreenwebfoundation/co2.js/compare/main...tackaberry:co2.js:bt/remove-debug?expand=1

Want a PR?

Before

/co2.js$ du -h --max-depth=1 ./dist/
166K    ./dist/cjs
41K     ./dist/esm
108K    ./dist/iife
315K    ./dist/

After

/co2.js/dist$ du -h --max-depth=1 ./dist/
165K    ./cjs
41K     ./esm
76K     ./iife
282K    .
mrchrisadams commented 1 year ago

Good idea fish, let's get rid of it 👍