Combining JS files to one script

That’s a lot of requirements and features. You will probably have hard time finding one single plugin that handles all of that. Maybe some premium plugin might do it, I don’t know. You just need to keep going through different plugins and dig into their source codes to find different pieces of the puzzle.

If you want to create your own custom solution, then perhaps it could be worthwhile to familiarize yourself with $wp_scripts and $wp_styles globals. I haven’t worked with them personally, but I think you should be able to get all of the scripts and styles from them for further processing.

Also the WP_Scripts class might provide you some insight.

P.s. Although asking for plugin recommendations is off-topic here and I think giving such is also frowned upon, I still want to mention LSCache. I’m not an affiliate, but I’ve used it a few times. The plugin does quite many things and browsing its source code could give you some ideas for your custom solution.

P.p.s. As a personal experience regarding using some of the existing popular plugins to merge and minify js and css assets, it has never ended well. I’ve always ended up with some css or js getting messed up, thus breaking the whole site. There’s just too many moving parts (actually plugin authors and coding styles) to make it work.