Hi @SebKrantz,
My real constraints function is significantly more complex and there this gives an error.
There are a lot of replies in this thread that are talking in generalities. It will be much easier if you can provide a reproducible example of your true problem.
The official suggestions are probably:

If you can write out your expressions algebraically. Do that instead.

If you must use the functional form, use Nonlinear Modeling · JuMP like you have tried:
model = Model(Ipopt.Optimizer)
@variable(model, x[1:n])
@objective(model, Min, objective(x...))
@constraint(model, constraints(x...) .<= 0)
optimize!(model)
But this will only work if you can trace your functions, which is seems like you cannot.
If neither of those things are appropriate. JuMP is not the right tool for the job.
In any case, not really concinved that the interface is suitable to put large scale tasks into production.
JuMP can and is used to solve very large scale nonlinear programs. See, e.g., AC Optimal Power Flow in Various Nonlinear Optimization Frameworks  #81 by ccoffrin.
However, one downside to Julia (and JuMP) is that a direct translation from MATLAB is often the wrong approach. If you can provide a reproducible example, people may have more concrete suggestions for improvements.