The first option is the one chosen by gnome-builder. gnome-builder tightly integrates with flatpak and doesn’t actually build things in the context of the gnome-builder sandbox and its runtime, instead if recursively creates other sandboxes for builds. This means that you get to pick any runtime for your builds which may be completely different than the one that runs gnome-builder itself. This is quite powerful, but requires a lot of intimate support for this model in the IDE.
There’s a variant of this - which is for the IDE to do builds in a container. If the end thing you are creating is a graphical application, then doing the builds as Flatpak builds makes a lot of sense. If the end thing you are creating a server app, then a container build is going to work better - and also allows using prepackaged Fedora dependencies. I don’t know of any examples of setting up a Flaptak’ed IDE to target container builds, but many IDE’s will have some sort of container support that can potentially be adapted for this purpose.