I think I’ve solved it.
Replaced
UEBuildConfiguration.bBuildEditor
with
Target.Type == TargetType.Editor
I no longer get errors related to editor-only types when compiling Development or DebugGame, and my editor module functionality still works when I compile with DebugGame Editor or Development Editor.
Packaging a project is still failing when cooking assets, but so far it doesn’t seem to be related to this.