  Let $H$ be an $h$-vertex graph. The vertex arboricity $ar(H)$ of $H$ is the
least integer $r$ such that $V(H)$ can be partitioned into $r$ parts and each
part induces a forest in $H$. We show that for sufficiently large $n\in
h\mathbb{N}$, every $n$-vertex graph $G$ with $\delta(G)\geq
\max\left\{\left(1-\frac{2}{f(H)}+o(1)\right)n,
\left(\frac{1}{2}+o(1)\right)n\right\}$ and $\alpha(G)=o(n)$ contains an
$H$-factor, where $f(H)=2ar(H)$ or $2ar(H)-1$. The result can be viewed an
analogue of the Alon--Yuster theorem \cite{MR1376050} in Ramsey--Tur\'{a}n
theory, which generalises the results of
Balogh--Molla--Sharifzadeh~\cite{MR3570984} and Knierm--Su~\cite{MR4193066} on
clique factors. In particular the degree conditions are asymptotically sharp
for infinitely many graphs $H$ which are not cliques.
