sebhildebrandt / systeminformation

System Information Library for Node.JS
MIT License
2.69k stars 305 forks source link

Smaller library size with treeshaking or granular imports #828

Open pastelsky opened 1 year ago

pastelsky commented 1 year ago

Is your feature request related to a problem? Please describe. Currently, it isn't possible to load specific parts of the system information as the library doesn't support tree-shakeable named imports or granular nested imports.

Moreover, due to the nature of the library, it is perhaps only expected to grow in size as support for more device variants are added. Given this library mentions being small in size as a goal, having granular imports / tree shakeable imports could be quite useful.

Currently, the library pulls in ~250+ KB of minified JS even if I only want to use a single function. When bundling this library in a yarn plugin, or a CLI tool, can add a lot of cruft.

Would you consider adding support for individual imports e.g. `import cpu from 'systeminformation/lib/cpu' ? That might be the easiest way with the current structure provided TS types are provided for these individual entry points.

sebhildebrandt commented 1 year ago

@pastelsky ... you are right. Version 6 (working on it already) is a complete rewrite (and all in TS) and will support this as it is much more granular Here you can import just the needed functions and this will reflect in a much smaller size. Hope I can finish this new transition soon.

sebhildebrandt commented 1 year ago

@pastelsky I currently making good progress with the new version. This version will allow to

So imports can be very specific and granular. Hope to have the first public beta ready in September.