0

I have a problem where my grunt-contrib-requirejs task stops my grunt processes. It does this with no errors at all. I need help identifying the issue.

My overall task

grunt.registerTask('build', [
    'clean:dist',
    'jshint',
    'handlebars',
    'requirejs',
    'concat:dist',
    'uglify',
    'compass',
    'imagemin',
    'cssmin',
    'copy'
]);

This is my task configuration

requirejs: {
    dist: {
        options: {
            baseUrl: 'app',
            optimize: 'none',
            optimizeCss: 'none', // We use cssmin for this
            preserveLicenseComments: true,
            dir: 'dist/',

            useStrict: true,
            wrap: false,
            findNestedDependencies: true,

            //If set to true, any files that were combined into a build bundle will be
            //removed from the output folder.
            removeCombined: true,

            paths: {
                aura: '<%= settings.bower %>/aura/lib/aura',
                underscore: '<%= settings.bower %>/underscore/underscore',
                eventemitter: '<%= settings.bower %>/eventemitter2/lib/eventemitter2',
                backbone: '<%= settings.bower %>/backbone/backbone',
                handlebars: '<%= settings.bower %>/handlebars/handlebars',
                text: '<%= settings.bower %>/requirejs-text/text',
                jquery: '<%= settings.bower %>/jquery/jquery'
            },

            shim: {
                backbone: {
                    exports: 'Backbone',
                    deps: ['underscore', 'jquery']
                },
                underscore: {
                    exports: '_'
                },
                handlebars: {
                    exports: 'Handlebars'
                }
            },

            modules: [{
                name: "app",
                include: ["aura","jquery"]
            }],

            onBuildWrite: function( name, path, contents ) {
                grunt.log.writeln( 'Writing: ' + name );
                return contents
            },

            done: function(done, output) {
                var duplicates = require('rjs-build-analysis').duplicates(output);

                if (duplicates.length > 0) {
                    grunt.log.subhead('Duplicates found in requirejs build:');
                    grunt.log.warn(duplicates);
                    done(new Error('r.js built duplicate modules, please check the excludes option.'));
                }

                grunt.log.writeln('All done');

                done();
            }

        }
    }
}

I tried running it with the -v flag, but I get no errors or warnings. It then just stops, and does not run the other tasks that I defined, I don't get the custom loggings that I defined. I get this output:

Running "requirejs" task

Running "requirejs:dist" (requirejs) task
Verifying property requirejs.dist exists in config...OK
File: [no files]
Options: logLevel=0, done=undefined, baseUrl="app", optimize="none", optimizeCss="none", preserveLicenseComments, dir="dist/", useStrict, wrap=false, findNestedDependencies, removeCombined, paths={"aura":"bower_components/aura/lib/aura","underscore":
"bower_components/underscore/underscore","eventemitter":"bower_components/eventemitter2/lib/eventemitter2","backbone":"bower_components/backbone/backbone","handlebars":"bower_components/handlebars/handlebars","text":"bower_components/requirejs-text/t
ext","jquery":"bower_components/jquery/jquery"}, shim={"backbone":{"exports":"Backbone","deps":["underscore","jquery"]},"underscore":{"exports":"_"},"handlebars":{"exports":"Handlebars"}}, modules=[{"name":"app","include":["aura","jquery"]}], onBuild
Write=undefined
>> Tracing dependencies for: app

It seems from this output that the done function is not defined, but I did define it, I even used a example from the grunt-contrib-requirejs readme.

I'm using grunt@0.4.1 and grunt-contrib-requirejs@0.4.1 with requirejs@2.1.8. Node is version v0.8.16

Update one

I tried upgrading my Node, I'm now on v0.10.17 but no changes here.

I removed aura from my modules include, it now looks like this:

modules: [{
    name: "app",
    include: ["jquery"]
}],

This gave me a little more input, but it still stops my Grunt, and does not run my done function, I get this output:

>> app.js
>> ----------------
>> bower_components/aura/lib/platform.js
>> bower_components/aura/lib/base.js
>> bower_components/aura/lib/logger.js
>> bower_components/aura/lib/aura.extensions.js
>> bower_components/aura/lib/aura.js
>> app.js
Allan Kimmer Jensen
  • 4,333
  • 2
  • 31
  • 53
  • I would try 2 things to try to find where the problem is: 1. It seems to me according to [this example](https://github.com/jrburke/r.js/blob/master/build/example.build.js) that you set your base url wrong. it should be **'app/'** 2. Try to skim down your options for requirejs to a bare essential minimum, and see if it's still not running. I would guess that currently it's stuck on locating dependencies for your app **app**. Try those things and we'll see what else can be done – Gilad Peleg Aug 23 '13 at 13:56
  • I tried both things, but no luck - still the same output. – Allan Kimmer Jensen Aug 28 '13 at 08:37
  • I removed the `aura` from my include and it seems to work now, at least finding dependencies, but after that it stops my grunt and does not run my done function. – Allan Kimmer Jensen Aug 28 '13 at 09:25

3 Answers3

2

The issue is that your done function is failing and the grunt task wasn't set up to forward the error to you. I made a PR that you can look at here to resolve the issue.

jamesplease
  • 12,547
  • 6
  • 47
  • 73
1

I found my problem as a issue on GitHub here: https://github.com/gruntjs/grunt-contrib-requirejs/issues/37

But there is no solution yet, I might have to look in to the error myself.

Allan Kimmer Jensen
  • 4,333
  • 2
  • 31
  • 53
0

If you remove the entire "done" section from the requireJS options, it won't halt the task list execution, however you will loose the ability to perform analysis on your compiled code

PeteAUK
  • 968
  • 6
  • 16