Let $f:X\rightarrow Y$ be a morphism of projective varieties. We may assume that $X$ and $Y$ are smooth, and $f$ is flat of relative dimension one. Fix an ample divisor $A$ on $X$.

I would like to ask if there exists a compact moduli space $\overline{M}_{g,d}(X)$ such that all points of $\overline{M}_{g,d}(X)$ represent curves $C\subset X$ of arithmetic genus $g$ and degree $d$ (with respect to $A$) with the following additional property:

$(\star)$ none of the irreducible components of $C$ is contracted by $f$.

Thank you.