How to declare C++ only be compiled within editor?

I have a class XXX inherited with AGeneratedDynamicMeshActor and this class is marked to be Editor only and DynamicMesh plugin can be used only with editor.
So i moved dependency to

if (Target.Type == TargetType.Editor)
		{
			PublicDependencyModuleNames.AddRange(
				new string[]{
					"AnimationBlueprintLibrary",
					"AnimGraph",
					"GeometryScriptingEditor"
				});
		}

But now when i’m trying to package project i get an error:

Couldn’t find parent type for ‘XXX’ named ‘AGeneratedDynamicMeshActor’

So how do I make XXX to be compiled only with editor?
Or hot to declare a dummy of AGeneratedDynamicMeshActor for shipping?

Try using

#if WITH_EDITOR

class …

#endif

I’ve tried. Still got same error:

Error: Couldn’t find parent type for ‘XXX’ named ‘AGeneratedDynamicMeshActor’ in current module