New 2-wire cable is run from the receptacle to the new light fixture. At the receptacle the wires are removed and each one is spliced to the new cable and back to the receptacle with a pigtail splice. At the light fixture box the black wire connects to the hot terminal, the white connects to the neutral terminal and the ground to any metal grounding terminal on the fixture, outlet box, or both.
The source neutral wire on the receptacle is removed and spliced to the white running to the switch, and to a pigtail back to the receptacle neutral. At the switch, the neutral wire is needed to power some dimmer switches and is now required in most switch boxes.
This diagram shows the wiring for a switch to control multiple receptacles. The source for the circuit is at the switch and the receptacles are wired using pigtail splices to make the connections.
This diagram shows the wiring for a new receptacle added from a light switch. The switch must have an always-hot wire for the source and a neutral wire must be present for the return path. The hot source is spliced with a pigtail back to the switch, and to a new 2-wire cable running to the new outlet. The neutral is spliced in the switch box to both the existing light, and the cable to the new receptacle.