[build] Improve bundling external libraries