create factory for AMD and Node modules