Excluding Modules from compiling for target client

I have plugin that have server side code. I don’t want the client to compile the code, and if it’s possible, I don’t want to add macro #if WITH_SERVER_CODE everywhere.

Is it possible to exclude modules compiling on client side?
Based on: Unreal Engine Modules | Unreal Engine 5.1 Documentation | Epic Developer Community
I should able to use "ExcludelistTargets " : 【“Client”】but the when I try build Development client, the intermediate directory for the modules still generated and compile.
Is ExcludelistTargets feature broken?

I tried IncludelistTargets too, with only “Server” and “Editor”, but the module still built on Development server

In case anyone else stumbles across this, the official docs are still wrong as of 5.6. After hunting through the source code I found the supported parameters for including/excluding modules are actually:

  • PlatformAllowList/PlatformDenyList
  • TargetAllowList/TargetDenyList
  • TargetConfigurationAllowList/TargetConfigurationDenyList
  • ProgramAllowList/ProgramDenyList
  • GameTargetAllowList/GameTargetDenyList