Let $X$ be a complex manifold and $Y\subset X$ a compact complex submanifold of codimension $1$. Let $f:X\to Z$ be a continuous map such that $f|_{X\setminus Y}$ is biholomorphic and $f|_Y$ is constant/holomorphic.
Is $f$ holomorphic under this conditions? If not, what is a suitable criterion to check?
This question came up in the context of resolution of singularites, so $Y$ can be thought of as an exeptional divisor and I want to check that $f$ is a resolution of singularities/bimeromorphic.