Welcome to TRS
Yes, when swapping engine sizes in a Ranger there is no benefit in using another "Ranger" engine size, in fact it has a down side in the reduced value of vehicle, because which would you rather buy a factory 4.0l Ranger or a 2.3l Ranger converted to 4.0l?
Same parts are needed when swapping in a V8 into a Ranger and there were no Factory V8 Rangers, well production V8 Rangers, lol.
But yes, you need the engine and transmission set, in 2WD or 4x4 to match what you have, then the engine computer, engine wiring harness and some of the engine bay wiring depending on the year of the donor vehicle
Its often less expensive to fix current Ranger and then sell it, then buy a Ranger with the larger engine you want