Let's say we have 2 js modules (A, B) that require a common module 'C' which is a Singleton or has static methods. If they both require the same instance of C then everything is fine. But if for some reason the require method will resolve to different files (for example, if they require different versions or if the C module was bundled inside one of them) then we will have 2 different instances of C, even though it is setup as a singleton.
How can we force the singleton patter in javascript even when the code can exist twice? Can I use the global namesapce, or are there any better patterns? If so, how do I use global correctly?