[package.js] Selecting individual files from packages


#1

For as far as I can see, it is currently only possible to include an entire package. Would it be good to be able to include separate files from a package?

For example, if I only need the ‘template’ function of lodash, I find it both inelegant and irresponsible (e.g. towards mobile users who pay for every kB they have to download) to include a file that contains much more functions, leading to a file size up to 10x bigger than needed.

Currently I’m including custom built files from libraries like lodash, but that’s undesirable because it involves all kinds of extra steps, for which package definitions should be a short-cut.

Being able to write modular packages, from which other package/app developers can choose the modules they need, also leads to an incentive to limit internal dependencies, thereby conforming more to for example the open-closed principle (see http://www.objectmentor.com/resources/articles/ocp.pdf). In my experience that leads to a better overall design (including testability) of my packages.


#2

Doesn’t it go against the encapsulation principle ?