The library has to be written in such a way that rollup can understand the parts and how to separate them. jQuery is a particularly bad anti-example as it attaches everything to a global object, sometimes dynamically. You might be better off using alternatives that work better with rollup that use ES modules.