There's also rollup.js (another module bundler) that supports tree-shaking: http://rollupjs.org/
Either way, it seems like the code needs to be using ES6 modules to make it all work.
https://github.com/systemjs/builder/pull/205
ES6 modules allow devs to easily specify and import only the parts of a library that are being used. The bundler takes care of pulling in the necessary parts. No magic required.
There's also rollup.js (another module bundler) that supports tree-shaking: http://rollupjs.org/
Either way, it seems like the code needs to be using ES6 modules to make it all work.