1

I've been fiddling with this for hours now and it's driving me mad. The network tab of chrome doesn't even show jquery being loaded and yet it's in exactly the same place in bundleconfig as it was before and scripts either side of it (including jquery-ui) are loading just fine.

I don't have a clue how to debug this - it just doesn't want to work!

Relevant part of bundleconfig:

    bundles.Add(New ScriptBundle("~/scripts/vendor") _
                .Include("~/scripts/jquery-{version}.min.js") _
                .Include("~/scripts/jquery-ui-{version}.min.js") _
                .Include("~/scripts/bootstrap.min.js") _
                .Include("~/scripts/fancytree/jquery.fancytree.js") _

Top of main.js:

requirejs.config({
    paths: {
        'text': '../Scripts/text',
        'durandal': '../Scripts/durandal',
        'plugins': '../Scripts/durandal/plugins',
        'transitions': '../Scripts/durandal/transitions'
    }
});

define('jquery', function () { return jQuery; });
define('knockout', ko);

define(['durandal/system', 'durandal/app', 'durandal/viewLocator'], function (system, app, viewLocator) {

The line in main.js that says:

define('jquery', function () { return jQuery; });

creates an error in the console: "Uncaught ReferenceError: jQuery is not defined" and I'd guess this is because the jquery script hasn't been loaded.

TheMook
  • 1,531
  • 4
  • 20
  • 58
  • I ran into this today too: http://stackoverflow.com/questions/18423253/mvc-bundling-failed-to-load-resource I don't know if it's related, but my temporary solution is to run in debug mode vs release to prevent everything from getting bundled/minified. – RobVious Aug 25 '13 at 00:20
  • 1
    Still not sure what the problem is, but removing ".min" from the two jquery lines in bundleconfig makes the non-minified jquery files load up fine. bootstrap.min.js still loads up just fine though so I'm really not sure what's going on! – TheMook Aug 26 '13 at 10:03
  • Just in case.. Are you loading the bundles before the call to main.js using require.js??? – margabit Aug 26 '13 at 14:38
  • Erm... possibly? My index.vbhtml file has this at the bottom: @Scripts.Render("~/scripts/vendor") – TheMook Aug 26 '13 at 16:58

2 Answers2

1

Be mindful that the BundleConfig, by default, ignores javascript files that have .min in the file name when running in DEBUG mode.

I always include this line first inside the RegisterBundles() function:

bundles.IgnoreList.Clear();

You can then add your own entries to the ignore list, like this:

bundles.IgnoreList.Ignore("*.intellisense.js");
bundles.IgnoreList.Ignore("*-vsdoc.js");
bundles.IgnoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
Brett
  • 4,268
  • 1
  • 13
  • 28
  • Thanks for the input Brett, but that's not it. My bundleconfig already does all that. This was working perfectly before upgrading Durandal from 1.2 to 2.0. Some other scripts also got updated though (I did an "update packages" command from the console and it upgraded everything) so I don't know where the fault was introduced. The fact remains that there are .min and normal js files in the same directory, so the bundleconfig file should load the normal files even if ".min" is specified. It isn't doing this and ONLY works if I remove ".min" from the definition. – TheMook Aug 27 '13 at 08:31
0

Try to put this code in the beginning of your BundleConfig file:

BundleTable.EnableOptimizations = false;
bundles.IgnoreList.Clear();
kleopatra
  • 51,061
  • 28
  • 99
  • 211
Tamara
  • 1
  • 1