Requirejs 在gulp任务中加载require.js模块

Requirejs 在gulp任务中加载require.js模块,requirejs,gulp,Requirejs,Gulp,我有一个require.js模块,它在我的应用程序模块上运行一些基准测试。通常这是通过benchmarksRunner.html手动打开的 require.config({ paths: { 'someDependencies': ['someDependenciesPath'], }, }); require([ 'someModulePath' ], function ( someModule ) { doSomeStuff

我有一个require.js模块,它在我的应用程序模块上运行一些基准测试。通常这是通过
benchmarksRunner.html
手动打开的

require.config({
    paths: {
        'someDependencies': ['someDependenciesPath'],
    },
});

require([
    'someModulePath'
], function (
    someModule
) {
    doSomeStuff
    return someResults (or dispatch event...)
});
有时我想使用gulp将这些结果保存在一个json文件中。我知道了如何将json保存到我想要存储结果的确切位置,但首先我被困在了如何将基准测试的结果检索到gulp中

gulp.task('performance', function () {

    // Obviously this does not work...
    require('./src/libs/require/require.min.js');
    require('./tests/benchmarksMain.js');

    // I want to run the benchmarks as they are already 
    // configured in the benchmarksRunner.html using require.js

    // Somehow gulp should be able to start the require.js scripts
    // and wait for an arbitrary event, then run the code from bellow
    // (which works just fine)

    performanceResults = {'someResults': results};

    var fs = require('fs'),
    var json = JSON.parse(fs.readFileSync('./tests/performance/performance.json'));
    json[dateFormat()] = performanceResults;
    json = JSON.stringify(json);

    return stringSrc('performance.json', json)
       .pipe(gulp.dest('tests/performance'))
}); 

function stringSrc (filename, string) {
    var src = require('stream').Readable({ objectMode: true });
    src._read = function () {
        this.push(new gutil.File({ cwd: "", base: "", path: filename, contents: new Buffer(string) }));
        this.push(null)
    };
    return src
}

谢谢

回复似乎已消失的答案:
node amd require
似乎是解决方案,它有路径配置对象。但是,它会引发异常:
AssertionError:path必须是字符串。看起来它无法使用阵列同时加载多个模块<代码>要求(['engine/utils/utils','benchmark'],函数(utils,benchmark){})