Simply get rid of the local modules.
They can easily be copy pasted out into a separate file and made into separate modules. Any entities that are used by the surrounding module can be defined in a definition module and exported. The former hosting module can then import those identifiers back in.
Local modules should never have been part of the language. This was one of those silly fads of the 1970s where everybody and their dog wanted to make everything "orthogonal" even if there was absolutely no reason to do so, even when doing so would come with a long list of disadvantages, even if doing so unnecessarily increased complexity. Just get rid of them.