0

我有一个问题,我的grunt-contrib-requirejs任务停止了我的 grunt 进程。它完全没有错误地做到这一点。我需要帮助确定问题。

我的总体任务

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

这是我的任务配置

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();
            }

        }
    }
}

我尝试使用-v标志运行它,但没有收到任何错误或警告。然后它就停止了,并且不运行我定义的其他任务,我没有得到我定义的自定义日志记录。我得到这个输出:

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

从这个输出看来, done 函数没有定义,但我确实定义了它,我什至使用了grunt-contrib-requirejs 自述文件中的一个例子中的一个例子。

我正在使用grunt@0.4.1和。节点是版本grunt-contrib-requirejs@0.4.1requirejs@2.1.8v0.8.16

更新一

我尝试升级我的节点,我现在开始了,v0.10.17但这里没有任何变化。

aura从我的模块中删除了包括,它现在看起来像这样:

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

这给了我更多的输入,但它仍然停止了我的 Grunt,并且没有运行我的完成功能,我得到了这个输出:

>> 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
4

3 回答 3

2

问题是您的done功能失败并且未设置 grunt 任务以将错误转发给您。我做了一个PR,你可以看这里来解决这个问题。

于 2014-02-26T02:28:45.820 回答
1

我在 GitHub 上发现了我的问题:https ://github.com/gruntjs/grunt-contrib-requirejs/issues/37

但是还没有解决方案,我可能不得不自己查看错误。

于 2013-09-02T10:04:55.230 回答
0

如果您从 requireJS 选项中删除整个“完成”部分,它不会停止任务列表的执行,但是您将失去对已编译代码执行分析的能力

于 2014-02-06T15:54:35.487 回答