Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Properly handle rjs options.dir if used #703

merged 1 commit into from

5 participants


In rjs task if options.dir is set it is an absolute path, so using path.join on it and options.baseUrl (also an absolute path) creates a path to non-existant files. This is helpful if building named modules with rjs rather than a single file from usemin.


I think this is useful to land. Anyone opposed?




This fix is necessary if you want use named modules in rjs. There is an other pull request with nearly the same problem #711

@addyosmani addyosmani merged commit a63ce3d into yeoman:master

1 check passed

Details default The Travis build passed

The original code of using path.join(options.dir, options.baseUrl, + '.js') is the correct usage. The only problem is that both of options.dir and options.baseUrl become absolute path in the rjs.optimize's callback function..

Instead of using var basePath = options.dir || options.baseUrl to determine basePath, please use the following one instead.

grunt.registerHelper('rjs:optimize:js', function(options, cb) {
    var baseUrl = options.baseUrl; // copy options.baseUrl to baseUrl
        :    :    :
    rjs.optimize(options, function(out) {                                                                                                                        
        originals.forEach(function(m) {                                                                                                                            
        var filepath = path.join(options.dir, baseUrl, + '.js'); // it will fix the problem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 8, 2012
  1. @theshortcut

    handle either options.dir if building with r.js as named modules, or …

    theshortcut authored
    …options.baseUrl if using usemin
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 cli/tasks/rjs.js
5 cli/tasks/rjs.js
@@ -49,7 +49,8 @@ module.exports = function(grunt) {
rjs.optimize(options, function(out) {
originals.forEach(function(m) {
- var filepath = path.join(options.dir, options.baseUrl, + '.js');
+ var basePath = options.dir || options.baseUrl;
+ var filepath = path.join(basePath, + '.js');
.writeln('rjs optimized module: ' +
.writeln('>> ' + filepath);
@@ -61,4 +62,4 @@ module.exports = function(grunt) {
Something went wrong with that request. Please try again.