updates AMD and CommonJS exposing as factory method