Maybe the devs would buy this idea if it was separated from the existing upgrade (by mysterious universally available nanotech or invisible space barges)?
I vote for a station-requiring Refit command, perhaps with a tech line of its own.
Basic function(s) cut costs for upgrading ships when you do them at an equipped facility: yards by default, bases with necessary module(s), planets with necessary improvement.
Higher functions enable reverse engineering, the component swapping described in OP, and higher returns on scrapping hulls you built...