Minimal set of headers needed to compile a file in a plugin

So I started getting some build errors after upgrading to 4.19, I’m guessing due to some random changes in ordering of the unity builds or something.

Basically, I have a plugin with a bunch of cpp files. In one of them I use the various platform defines (e.g. PLATFORM_WINDOWS etc.) but don’t really touch any unreal stuff other than that. This used to compile without any includes at all (other than its corresponding header file, with a few function declarations), but now I get errors that these PLATFORM_FOO defines aren’t defined.

So I’m trying to figure out the right incantation to get the headers I want, without a bunch of other errors. E.g. I tried just including “CoreMinimal.h” but get:

In file included from D:/Documents/code/foo/unreal-engine/Engine/Source/Runtime/Core/Public\CoreMinimal.h:9:
  In file included from D:/Documents/code/foo/unreal-engine/Engine/Source/Runtime/Core/Public/CoreTypes.h:9:
  D:/Documents/code/foo/unreal-engine/Engine/Source/Runtime/Core/Public/Misc/Build.h(45,3):  error: Exactly one of [UE_BUILD_DEBUG UE_BUILD_DEVELOPMENT UE_BUILD_TEST UE_BUILD_SHIPPING] should be defined to be 1
          #error Exactly one of [UE_BUILD_DEBUG UE_BUILD_DEVELOPMENT UE_BUILD_TEST UE_BUILD_SHIPPING] should be defined to be 1
           ^

So clearly I’m missing something. I’ve tried a few other headers that seem like they might give me what I want (e.g. Engine.h and Core.h) but it always end up with a bunch of similar errors.

So, what is the magical incantation of includes I need to get a file to build and give me access to these platform defines?

It’s worth noting that other files in the same plugin (and same folder) build just fine (they also use the platform defines), but even if I straight up just copy the same includes from those files into this particular file, it still doesn’t work. So there seem to be something mysterious going on.