2
votes

I'm using gulp-durandal to build our durandal app. It fails on our first module which has a depeendecy to knockout through:

define(['knockout',....

[09:35:27] Durandal Error: ENOENT, no such file or directory 'C:\xxxxx\app\knockout.js' In module tree: company/viewmodels/edit

at Object.fs.openSync (fs.js:438:18)

I have knockout defined as a patch in config.js (standard requirejs way) but it seems gulp-durandal does not resolve paths from config.js ?

'knockout': '../Scripts/lib/knockout/knockout-2.3.0',

How do you get gulp-durandal to use our config paths instead of trying to resolve the modules directly under the app folder ? I tried using options.extraModules but that only allows you to add paths to modules, not symbolic names for the module so that doesn't seem to be the correct way.

The basic structure of my durandaljs app follows the standard guidelines I believe, I have a config.js and main.js under the App folder.

My config.js:

define([], function() {
return {
    paths: {
        'text': '../Scripts/lib/require/text',
        'durandal': '../Scripts/durandal',
        'plugins': '../Scripts/durandal/plugins',   

My main.js

require(['config'], function(config) {
require.config(config);

require(['durandal/system', 'durandal/app', 'durandal/viewLocator', 'plugins/widget', 'custombindings'],
    function(system, app, viewLocator, widget) {
        ..... app code here.....

}

gulpfile.js:

var gulp = require('gulp');

var durandal = require('gulp-durandal');

require(['App/config'], function(config){
  console.log('loaded config');
});

gulp.task('durandal', function(){
durandal({
baseDir: 'app', //same as default, so not really required.
main: 'main.js', //same as default, so not really required.
output: 'main.js', //same as default, so not really required.
almond: true,
minify: true,
require:true
})
.pipe(gulp.dest('dir/to/save/the/output'));
});

I guess the question is how do I load my config.js paths into gulp so the paths are resolved correctly ? I tried:

var gulp = require('gulp');

var durandal = require('gulp-durandal');

require(['App/config'], function(config){
  console.log('loaded config');
});

But it seems require only wants a string as input (I guess require function in gulp != require from require.js)

1
A similar issues has been reported on GitHub: github.com/welldone-software/gulp-durandal/issues/20AlignedDev

1 Answers

0
votes

I believe the issue is that your gulp-durandal task needs configuration to mimic the config.js file. If you need further assistance please provide more code from your gulp-durandal task.