That would be the best way. However, the fan bay of the STOVAL version of JSF, with it’s unique power take off for the lift fan to power the system , is actually potentially configurable for a directed energy weapon. There were proposals being kicked around around in the mid 2000s to give it a go.
The new laser weapons are solid state, much smaller, more durable and require much less energy. Even mounted on small planes.
https://m.jpost.com/israel-news/israel-successfully-downs-targets-using-airborne-laser-system-671638