Closed mishushakov closed 7 months ago
This is an interesting point, something that we should consider looking into. The database is used by the greencheck hosting API in the library so isn't needed for emissions calculations. It looks like the database is used for testing (very quick assessment), so might be safe to exclude from the package.
There's a bunch of extra stuff in the data
folder that also gets packaged at the moment which are probably surplus to requirements as well.
@mishushakov are you able to tree-shake out the stuff you don't need, or is that not an option in your use case?
I'm not using it for frontend, so that's not an option currently
Reduced package size a bit by removing debug dependency in #144. Will keep looking for opportunities to shave off some more bytes.
It looks like some files are published in the npm package that don't need to be. I ran npm pack --dry-run
and got 74 results:
Many of these are needed but I'm sure some can be removed.
You could add them to .npmignore
. I'm happy to help but I don't know which files are necessary.
(Alternatively if you want to switch from npmignore
's blocklist style to an allowlist style, you can use the files
key in package.json.)
Looking at this again, there's probably a few changes we can make to reduce package size:
src/*
).dist/data
.Alternately, we should:
.map
files for ESM filesGuesstimating a reduction of about 200kB if we do this.
@mishushakov I'm closing this issue since release v0.14.1 is now published (unpacked size now 194 kB on NPM).
We're only using co2.js for calculating emissions, thus don't need the full 430 kB package Would be amazing if you could split the database and the calculator into separate sub-packages