         else
           udefine.modules[platform][name] = undefined
       @
-      
+
     remove: (name) ->
       for p in platforms
         if Object.hasOwnProperty.call udefine.modules[p], name
           delete udefine.modules[p][name]
       @
-    
+
     get: (name) -> udefine.modules[platform][name]
     set: (name, value) ->
       if typeof value is 'object'

      require path.join(process.cwd(), prePath, udefine.modules[type][name])
    else
      udefine.modules[type][name]
  
  # Main entry point
  udefine = (name, deps, factory) ->
    throw new Error 'A udefine module needs to have a name' unless name?
    
    unless name is name.toLowerCase()
      console.warn 'A module should be all lowercase'
    
    if typeof deps is 'function' or isObject(deps)
      [name, deps, factory] = [name, [], deps]
      
    # Define, either AMD or UMD (if any?)
    if define?
      result = define.apply @, arguments if define.amd or define.umd
    else
      depArr = (loadModule(dep, platform) for dep in deps)
      
      result = resolveModule factory, depArr
      
      # Set dependency if it does not exist
      unless Object.hasOwnProperty.call udefine.modules[platform], name
        udefine.modules[platform][name] = result
    
    # Automatically inject if property is set
    unless Object.hasOwnProperty.call udefine.inject.modules, name
      if udefine.autoInject
        udefine.inject.add name, {root, name} if udefine.env.globals
        
        # Auto injection does not work on CommonJS
        # TODO: Need to investigate if it's even possible
        ###

  # TODO: Find a better wording than platform and platforms
  platforms = ['commonjs', 'globals']
  platform = if hasModule then 'commonjs' else 'globals'

  # Helper function to resolve a module (either function or object)
  resolveModule = (factory, deps) ->
    if typeof factory is 'function'
      factory.apply @, deps
    else
      factory

  loadModule = (name, type) ->
    if hasModule and typeof udefine.modules[type][name] is 'string'
      # Prefer non-relative modules
      packageModule = try require udefine.modules[type][name]

      return packageModule if packageModule?

      path = require 'path'
      prePath = do ->
        if udefine.paths[type].base
