You must account for all the equipment to convert fuel into mechanical work as well. A battery is a large part of the equipment to covert electrons into useful electricity and electric motors and controller are comparatively light weight. Energy density is still higher I have done rough calculations that say batteries need to be at about 2000 wh/kg to be at parity with a diesel semi and the theoretic upper limit for lithium is 2600 wh/kg.