Mostly development, but also used partially at build time.
Somewhere. It is reused AFAIK in the build process and in the browser so it is not reused only for development and tests.
I think we could have dynamic dependencies there, that would inherit it from foreman, but that is quite complex.
This is very complicated issue and ppl are trying to figure out a way out: Rails 7 and new frontend approaches POC
But it won’t be fixed in a day given we’ve driven ourselves into that mess three years