I've found out that weyland optimizer replaces the paths in the javascript files with their real values. But it doesn't replace the paths used in middle of the code using require function.
For example:
require('myscripts/mymodule', function(mymodule){
// do something after mymodule is ready.
}
and I'm defined myscripts as a path like:
'myscripts': 'api/ScriptHandler/GetModule'
RequireJS' optimizer needs its build file to have
findNestedDependencies: trueto find such cases. If Weyland uses RequireJS' optimizer behind the scenes (ETA: it does) this might be the solution.