Make `GenJSFiles` flexible enough to handle VirtualFiles

This means not-NPEing due to their lack of physical existence, and properly writing to `baseDir` when it is a VirtualDirectory rather than dumping all its output inconveniently on the filesystem.