add factory code for RequireJS