Suppose you buy yersef a Glock 27... a baby Glock in .40 S&W.
You can get an Xgrip and a G22 mag, and have a G22 (Compact) sized grip, basically, with the shorter slide.
You can get a G22 barrel and install it, and have a little longer .40 barrel for ballistics.
I believe the G22 slide will work on the G27 frame but the spring will be exposed.
Install a G32 (or G33) barrel and you can shoot 357 SIG, in whichever length you want. (G27 or G22 mag still works fine.)
There are aftermarket 9mm barrels for the G22... YMMV, but many people have no issues. Not something I would carry, but for range fun sure.
This is one example. But for another, A G17 barrel or slide won't work on a G19 frame... even tho the G19 slide or barrel works fine with a G26. So you have to research.