@@ -113,12 +113,19 @@ function debugModule(module, runtime) {
113113
114114 // runtime is the prototype of wrappedRuntime
115115 // so we can access all runtime properties too
116− var wrappedRuntime = Object.create(runtime, {
117− notify: wrapNotify,
118− runDelayed: wrapRunDelayed
116+ var wrappedRuntime = Object.create(runtime);
117+ wrappedRuntime.notify = wrapNotify;
118+ wrappedRuntime.runDelayed = wrapRunDelayed;
119+
120+ var assignedPropTracker = Object.create(wrappedRuntime);
121+ var moduleInstance = module.make(assignedPropTracker);
122+ // The main module stores imported modules onto the runtime.
123+ // To ensure only one instance of each module is created,
124+ // we assign them back on the original runtime object.
125+ Object.keys(assignedPropTracker).forEach(function(key) {
126+ runtime[key] = assignedPropTracker[key];
119127 });
120128
121− var moduleInstance = module.make(wrappedRuntime);
122129 var moduleNodes = flattenNodes(wrappedRuntime.inputs);
123130 var tracePath = tracePathInit(runtime, moduleInstance.main);
124131