Sorry, for not being clear enough. Yes, it is a multiple step process. We are first converting CommonJS, AMD and ECMAScript 6 libraries that have been included by the user to Google Closure modules and then later pass all sources in a single step to the Google Closure compiler for optimization. In order to figure out which sources to pass to the Google Closure compiler for optimization, we are creating a data structure for each JavaScript library, with information such as if it is a Google Closure library, which namespaces it provides, which other modules it requires, etc. To get some of those information from a Google Closure module, we are parsing the goog.require and goog.provide statements.
I think I figured out, where I went wrong. If you don't have the loadAddress of the required module, you cannot really rewrite the require statement, since you cannot get the new module name without the loadAddress. Would it be an option to create the module name from the string given in the require statement in case the loadAddress cannot be found? But that would be quite similar to the previous approach then, right?
But overall, I am happy to try to pass all known sources to the compiler as inputs when converting a JavaScript module ;)