Fix "TypeError: Cannot call method 'replace' of undefined" error when using "modules" and "dir" settings in the r.js build file.