module Modulr
  class SyncCollector < Collector
    def add_module_from_path(path)
      js_module = super(path)
      modules << js_module unless modules.include?(js_module)
    end
    
    private
      def lib
        File.read(PATH_TO_MODULR_SYNC_JS)
      end
    
      def requires
        top_level_modules.map { |m| "\n  require('#{m.id}');" }.join
      end

  end
end
module Modulr
  class SyncCollector < Collector
    def add_module_from_path(path)
      js_module = super(path)
      modules << js_module unless modules.include?(js_module)
    end
    
    private
      def lib
        output = File.read(PATH_TO_MODULR_SYNC_JS)
        if top_level_modules.size > 1
          output << "\nvar module = {};\n"
          output << "\nrequire.main = module;\n"
        end
        output
      end
      
      def requires
        top_level_modules.map { |m| "\n  require('#{m.id}');" }.join
      end

  end
end
Make main module global when handling more than one file at the same time.
Make main module global when handling more than one file at the same time.