How to exlude Editor from shipping build

Hey everyone! I have Bluetility C++ script which uses some Editor functionality. For the shipping, I am surrounding my code with #if WITH_EDITOR

and inside build.cs I do:

if (UEBuildConfiguration.bBuildEditor)
{
    PublicDependencyModuleNames.AddRange(new string[] { "UnrealEd" });
}

And still, if Shipping configuration is selected, I do get error about editor modules being included. I am missing something else important?

I see nobody at Epic cares to reply, posted similar question, but nobody cares apparently. Did you by any chance figure out what is causing this? My game was cooking fine on 4.13, the moment i switched to 4.17 it started shouting at me that im using some editor modules

4.19 here, but replacing UEBuildConfiguration.bBuildEditor for Target.Type == TargetType.Editor solved it for me.