I agree, you're going to need the same year or newer.
The list is long, if you really want a 4.0L I'll give some big ticket items to help narrow some things down:
-Engine with exhaust
-transmission (Every Ranger engine has a different manual transmission, yes they're all M5OD's but the main casting is different)
-motor mounts including the frame side brackets and for a 4L those are going to be specific to 2 wheel drive '90-97, if you find a donor '98+ that would work too but adds extra complications
-engine computer obviously
If you find a '98 or newer the V6 models also had the PATS anti theft system which is in the dash and will need to be retained or deleted, but also in '98 they went to returnless fuel system and a higher pressure so you will need to change a bunch of that stuff too, not to mention a bunch of stuff moved like the carbon canister to under the bed and stuff...
So yes, a donor vehicle is more ideal...