I gave the updated code a try but the issue still persists.
Perhaps the screen dump above may help.
As a workaround I could disable optimising JS save and clear the cache. Clear Hyper Cache so my site visitors still see a working page and re-enable after I've finished editing in VC.
Thanks
Peter