Also what was the last year the 5.9 was carberauted?
The last year the 5.9 was carburated from the factory was ... before it had the Magnum mounts.
OTOH, you can buy LA-pattern Magnum heads (EngineQuest CH318B comes immediately to mind) so you can use a LA carb intake. There are also some Magnum pattern carb intakes made.
(Pick the intake, then order the proper EQ heads to suit is my recommendation.)
That will also take using an LA distributor to get vacuum and centrifugal advance going properly; carefully running the new wiring (since none of the old engine wiring will work now!); and at this point, your transmission will be at risk due to the increased power. So upgrade the transmission; whoops, that new 4 speed auto won't bolt to your transfer case, so matching transfer case also.
If you're going to go EFI, then do note that the Dakota never came with the 5.9 in the first generation; HOWEVER - the 5.2 ECU will drive a 5.9 fine. If you want to be really picky, the 1996 was OBDII and several vendors (Ryan Hogan of Flyin' Ryan Performance, FRP.COM and Marty Fletcher, UTAWESOME.COM comes to mind. Also HemiFever, but I have no link for that) can sell you a tuner pod that plugs in and adjust the parameters. The 1996 will come with the RE transmission if automatic; this picks up the overdrive over the 87 3 speed auto, and if the donor is the same wheelbase as your 1987, and both are 4x4, you should be able to transplant the drivetrain.
But at that point, you've just about "sold the 87 and buy a V8 4x4" level, with a lot more work.
And more money.
You really should define what you want to do, and why you want the work done.
(If it truly has sentimental value, why not just rebuild the motor? .030 over on bore, and a fresh rebuild, and you may be surprised how well it runs.)
One last thing to CONSIDER - the Magnum 3.9 had about the same horsepower (just a bit less torque) than the LA 5.2 had. Might want to keep it looking the same, go Magnum V6, and rewire to support the EFI. See https://www.allpar.com/mopar/318.html
for some history on the LA and Magnum motors.