It's not possible to do this without any component cost. Scrapping a weapon destroys its mods.
But it shouldn't take long to find a few spare weapons, break them down, and make enough components for a swap at a relatively low component cost. If you can manage to afford the Level 1 Scrapper perk this gets even easier.
It sounds like you might know how to do this already, but in case it helps you or others—let's say you have a Powerful Receiver mod on pistol A, and you want to move it to pistol B.
- At the weapons workbench, select Pistol A, select the Standard Receiver mod, then choose Build. Though this isn't free, it's really pretty component-cheap.
- Look in your inventory to confirm. You should see a Powerful Receiver mod in the Mods inventory tab. This mod is now available to apply to other pistols.
- At the crafting bench, choose Pistol B and navigate to the Powerful Receiver mod. Since you already have one, instead of Build you'll see an option to Attach.