There’s software for that. Honestly, i prefer that over the ‘whole package or nothing’ approach in Flatpack, which still has ~/.var for packages hardcoded btw.
Convenient libraries/frameworks are fat. Because they are fat, they need frequent updates/security fixes, breaking codebase more often. With flatpack, developers can freeze lib versions at a convenient point, without caring for system dependencies.