Here is an idea I have been following in the Yahoo SoundTraxx group. If you use a CL2 constant current device, the current will stay at 20ma when fed by anywhere from 5 volts to 90 volts. No resistor calculation needed. It is a LED driver. It can be used by 1.5 volt lamps also. Good for lamps that operate at 20ma. Some model railroad controllers operate above 12 to 14 volts and occasionally, someone has a burnt out 1.5 volt lamp because of that. Lamps are sensitive to voltage changes even with a resistor and the brightness can vary.
The CL2 is sold by Mouser Electronics. It is quite small.
Another option I found in a different DCC forum.
The LM317 can be used as a current regulator using one resistor.
Look at National’s application note. They are available in the same
TO92 package as well as SMT. I have used them with Miniatronics 1.5V
bulbs at just under 40ma as head and tail lights in trolleys. They
operate for 12hr days during shows and have been in service over two
years.
With the SMT wrapped in Kapton I slip them in the boiler between the
weight and shell in brass locos, but they require good soldering
skills and don’t drop them on/in the carpet.
I have not ried these options but they look very good.
Rich