You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 10, 2019. It is now read-only.
I have a project where there are test files in the same directory as source files (this keeps our code modular so we can move things around and tests follow). However, when we bundle our code, we don't want to be distributing our tests, so we use the moduleFilter property to exclude files that have the suffix 'Test' (this is general enough for our purposes). And FYI, we use Jasmine/Karma to run our tests.
So, in our durandal application, we use a few widgets. Therefore, in our main.js we require the widget plugin and register our widgets. However, in our test for one of the widgets, we also include the widget plugin. Since that test file is excluded, what seems to be happening is that it is rippling those excluded file's dependencies up. This means that the widget plugin doesn't actually get bundled, along with a handful of other dependencies (that are required by included files) such as jquery, knockout, bootstrap, and so on.
This happens on any module that is required in an excluded file. For instance, if you require knockout on a file that is in the moduleFilter, then knockout will not be bundled. If you require a module that has multiple dependencies in one of the files in the moduleFilter, then that module and all it's dependencies won't be bundled either.
gulp.task('clean',function(finished){del(['build/**/*'],finished);});gulp.task('index',['clean'],function(){returngulp.src('./src/index.html').pipe(htmlreplace({'js': 'main.js',})).pipe(gulp.dest('./build'));});gulp.task('durandal',['index'],function(){vargulpConfig={//Some defaultsverbose: true,baseDir: 'src',main: 'main.js',output: 'main.js',minify: false,moduleFilter: function(mn){varincluding=(mn).indexOf('foo')==-1returnincluding;},extraModules: ['bower_components/requirejs/require'],rjsConfigAdapter: function(rjs){extend(rjs,config);rjs.baseUrl='src';rjs.findNestedDependencies=true;//Needs to be true as some durandal modules have nested deps for pluginsreturnrjs;}};returndurandal(gulpConfig).pipe(gulp.dest('build/'))});
I have a project where there are test files in the same directory as source files (this keeps our code modular so we can move things around and tests follow). However, when we bundle our code, we don't want to be distributing our tests, so we use the moduleFilter property to exclude files that have the suffix 'Test' (this is general enough for our purposes). And FYI, we use Jasmine/Karma to run our tests.
So, in our durandal application, we use a few widgets. Therefore, in our main.js we require the widget plugin and register our widgets. However, in our test for one of the widgets, we also include the widget plugin. Since that test file is excluded, what seems to be happening is that it is rippling those excluded file's dependencies up. This means that the widget plugin doesn't actually get bundled, along with a handful of other dependencies (that are required by included files) such as jquery, knockout, bootstrap, and so on.
This happens on any module that is required in an excluded file. For instance, if you require knockout on a file that is in the moduleFilter, then knockout will not be bundled. If you require a module that has multiple dependencies in one of the files in the moduleFilter, then that module and all it's dependencies won't be bundled either.
Some Code
config.js
build.js
main.js
foo.js
Result
This because we exclude
foo.js
, we also end up excluding all it's dependencies, despitemain.js
requiringplugins/widget
Let me know if I need to make a repo where you can see this happen
The text was updated successfully, but these errors were encountered: