Same as swapping in a V8, without the benefit of the V8
You need to swap engine and transmission, computer and wiring harness
2004 was also first year for digital dash so you have to have a Ford Dealer "remarry" the dash with new computer as well as PATS system
And you end up with a Frankenstein vehicle where VIN doesn't match engine, so resale is less.
Ford made stock 4.0l Rangers so "Frankenstein" version doesn't have much appeal vs a V8 Ranger which Ford never made.
IMO best option is to fix, repair, swap out 3.0l for same engine, sell it and buy a 4.0l Ranger if thats what you want in the end, less work and CHEAPER