0

I'm have trouble with Bundleing and Minification..

Its a set up, if I have M&B on, it gets minified and added, I have ordering working correctly.. when M&B is off, eveything works fine. when M&B is on, everything is minified and loooks like it's created in the right order. but one of my scripts crashes when it's loaded... but only when bundled...or when Min&Bundled...

Here are the ones in question

<script type="text/javascript" src="@Url.JScript("jquery-ui-1.8.9.custom.min.js")" ></script>
<script type="text/javascript" src="@Url.JScript("jquery.validate.js")"></script>
<script type="text/javascript" src="@Url.JScript("jquery.unobtrusive-ajax.min.js")" ></script> 
<script type="text/javascript" src="@Url.JScript("grid.locale-en.js")"></script>
<script type="text/javascript" src="@Url.JScript("jquery.jqGrid.js")"></script>
<script type="text/javascript" src="@Url.JScript("grid.addons.js")"></script> <<<----- this one dies at load time when minified!!!

When its minified and grid.addon.js and gets loaded, it give the following error. Object doesn't support this property or method.

Here is the non minified bits in question

$.jgrid.extend({
// This is the ols search Filter method used in navigator.
    searchGrid : function (p) {

The error I get says that $.jgrid does not have an extend method.. When I debug and look at the loaded object, it is correct there is no .extend method on it.

But when M&B is off, everything works fine.

Here is my code for m&B in Global.asax.cs

public static void RegisterBundles(BundleCollection bundles)
        {
            BundleTable.EnableOptimizations = true;

            // http://stackoverflow.com/questions/12487742/asp-net-mvc4-bundling-minification-min-js-files-excluded-from-scripts-render
            BundleTable.Bundles.IgnoreList.Clear(); // apparently, IgnoreList included .min.js in debug
            BundleTable.Bundles.IgnoreList.Ignore(".intellisense.js", OptimizationMode.Always);
            BundleTable.Bundles.IgnoreList.Ignore("-vsdoc.js", OptimizationMode.Always);
            BundleTable.Bundles.IgnoreList.Ignore(".debug.js", OptimizationMode.Always);

            var styles = new StyleBundle("~/Bundling/RzrRootBundledcss").Include(
                                                                                    "~/Assets/CSS/Jcdc.css",
                                                                                    "~/Assets/CSS/jqueryslidemenu.css",
                                                                                    "~/Assets/CSS/ViewDetails.css",
                                                                                    "~/Assets/CSS/Site.css",
                                                                                    "~/Assets/CSS/UserInformation.css",
                                                                                    "~/Assets/CSS/ui.jqgrid.blue.css",
                                                                                    "~/Assets/CSS/blue/jquery-ui-1.8.9.custom.css",
                                                                                    "~/Assets/CSS/cupertino/jquery-ui-1.8.5.custom.css",
                                                                                    "~/Assets/CSS/Blueprint.css",
                                                                                    "~/Assets/CSS/BlueSite.css",
                                                                                    "~/Assets/CSS/timepick.css",
                                                                                    "~/Assets/CSS/ui.spinner.css"
                                                                                ).ForceOrdered();

            INetLog log = ObjectFactory.GetInstance<INetLog>();
            log.Debug("done mini and budle css");
            //ScriptBundle

            Bundle js = new Bundle("~/Bundling/RzrRootBundledjs");
            //js.Orderer = new AsIsBundleOrderer();


            BundleFileSetOrdering bundleFileSetOrdering1 = new BundleFileSetOrdering("RzrRootBundledjs");


            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery-1.4.2.min.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery-ui-1.8.9.custom.min.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.validate.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.unobtrusive-ajax.min.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/grid.locale-en.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.jqGrid.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/grid.addons.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/json2.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.validate.unobtrusive.jcdc.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/JcdcInputValidation.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.hoverIntent.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jqueryslidemenu.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.corner.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.ezpz_tooltip.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/../JQGrid/JQGridDefaults.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/JCDCEdit.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/JCDCAjaxNew.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.maskedinput-1.2.2.min.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.alphanumeric.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/additional-methods.js?version=1.0");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.livequery.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.blockUI.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/jquery.timePicker.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.debug.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.mapping-latest.debug.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.validation.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout.viewmodel.2.0.0.min.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/knockout-deferred-updates.js");
            bundleFileSetOrdering1.Files.Add("~/Assets/JavaScript/ui.spinner.js");
            bundleFileSetOrdering1.Files.Add("~/Content/ASPNetSpellInclude/include.js");

            bundles.FileSetOrderList.Clear();
            BundleTable.Bundles.FileSetOrderList.Insert( 0, bundleFileSetOrdering1 );


            //ScriptBundle js = new ScriptBundle("~/Bundling/RzrRootBundledjs");
            //js.Orderer = new AsIsBundleOrderer();
                                                                                  js.Include("~/Assets/JavaScript/jquery-1.4.2.min.js")
                                                                                 .Include("~/Assets/JavaScript/jquery-ui-1.8.9.custom.min.js")
                                                                                 .Include("~/Assets/JavaScript/jquery.validate.js")
                                                                                 .Include("~/Assets/JavaScript/jquery.unobtrusive-ajax.min.js" )
                                                                                 .Include("~/Assets/JavaScript/grid.locale-en.js")
                                                                                 .Include( "~/Assets/JavaScript/jquery.jqGrid.js")
                                                                                 .Include( "~/Assets/JavaScript/grid.addons.js")
                                                                                 .Include("~/Assets/JavaScript/json2.js")   
                                                                                 .Include("~/Assets/JavaScript/jquery.validate.unobtrusive.jcdc.js" )
                                                                                 .Include("~/Assets/JavaScript/JcdcInputValidation.js" )
                                                                                 .Include("~/Assets/JavaScript/jquery.hoverIntent.js" )   
                                                                                 .Include("~/Assets/JavaScript/jqueryslidemenu.js" )
                                                                                 .Include("~/Assets/JavaScript/jquery.corner.js")
                                                                                 .Include("~/Assets/JavaScript/jquery.ezpz_tooltip.js" )    
                                                                                 .Include("~/Assets/JQGrid/JQGridDefaults.js")
                                                                                 .Include("~/Assets/JavaScript/JCDCEdit.js")
                                                                                 .Include("~/Assets/JavaScript/JCDCAjaxNew.js")
                                                                                 .Include("~/Assets/JavaScript/jquery.maskedinput-1.2.2.min.js" )
                                                                                 .Include("~/Assets/JavaScript/jquery.alphanumeric.js")
                                                                                 .Include("~/Assets/JavaScript/additional-methods.js?version=1.0")
                                                                                 .Include("~/Assets/JavaScript/jquery.livequery.js")
                                                                                 .Include("~/Assets/JavaScript/jquery.blockUI.js")
                                                                                 .Include("~/Assets/JavaScript/jquery.timePicker.js")
                                                                                 .Include("~/Assets/JavaScript/knockout.debug.js")
                                                                                 .Include("~/Assets/JavaScript/knockout.mapping-latest.debug.js")
                                                                                 .Include("~/Assets/JavaScript/knockout.validation.js")
                                                                                 .Include("~/Assets/JavaScript/knockout.viewmodel.2.0.0.min.js")
                                                                                 .Include("~/Assets/JavaScript/knockout-deferred-updates.js")
                                                                                 .Include("~/Assets/JavaScript/ui.spinner.js")
                                                                                 .Include("~/Content/ASPNetSpellInclude/include.js");

            log.Debug("done minify and bundle script");

            bundles.Add(styles);
            bundles.Add(js);

            //BundleTable.EnableOptimizations = true;

            log.Debug("done generating bundles");
        }

    }

and here is my injection from the layout page.

    @Styles.Render("~/Bundling/RzrRootBundledcss");
    @Scripts.Render("~/Bundling/RzrRootBundledjs");

I looked into Jquery.JQgrid.js and it uses the .Extend method inside it's own code.. now i'm really confused.

So I have 2 questions...

  1. Anyone know what's going on that I'm clearly not fuly grasping?, or can give me hints as to wher to look? I'm starting to suspect minification is renaming the extend method...no idea how to fix that.
  2. How can I force the debugger to break on the loading

Any help or hints you can give would be greatly aprpeciated...

Eric Brown - Cal
  • 14,135
  • 12
  • 58
  • 97
  • 1
    Which version of jqGrid you use? Are you sure that you **really need** `grid.addons.js`? Why you insert **both** `jquery-ui-1.8.9.custom.css` and `jquery-ui-1.8.5.custom.css`. It look to be an error. What is `ui.jqgrid.blue.css`? You includes **very old** version of jQuery (`jquery-1.4.2.min.js`). Are you really need the retro version? – Oleg Mar 27 '15 at 21:48
  • We are porting a very large applicaiton fron powerbuilder to asp.neet MVC c#, so large that regression testing is a big deal and until we finish poritng we have several generation to pages out there, and are stuck on old version of jquery... I looked at removing grind.addons.js and it looks like wer are stil usign it on older pages. jqgrid.blue liets us use jqgrid wit out blueprinting (layout gutters and such)system. – Eric Brown - Cal Mar 30 '15 at 14:18
  • I don't like the answer, but i got ot working by pulling the bad js files out of the bundle.. i injet teh budndle, then in inject the bad file, and then i inject any files aht depend on the bad file...which thankfulya re very few.. If anyone has a better idea I'd love to hear it! – Eric Brown - Cal Mar 30 '15 at 14:20
  • 1
    The "regression testing" exist only theoretically. The problem is that old jQuery don't supports new **current versions of web browsers**. So you don't need retest your application if you want use it with IE8 or older, with retro versions of Chrome or Firefox and so on. If you would opens old demos which I posted on stackoverflow, then you will see horizontal scrollbar mostly, because new version of Chrome makes another calculation. It's just an example of compatibility. – Oleg Mar 30 '15 at 14:49
  • 1
    I'd recommend you to update jQuery to at least 1.7.x, jQuery UI to 1.8.x and jqGrid too. I published some time before [free jqGrid](https://github.com/free-jqgrid/jqGrid) (see [readme](https://github.com/free-jqgrid/jqGrid/blob/master/README.md) and [wiki](https://github.com/free-jqgrid/jqGrid/wiki)) which can be used under the same licence agreements MIT/GPLv2 as old versions of jqGrid or to use at least jqGrid 4.6. – Oleg Mar 30 '15 at 14:52
  • Thanks for the advice, so yo are saying that you think bundling and minfication are failing becasue i have old version of the packages? Or are you just suggesting it in gernal, not connected toteh bundling andminfication side of the probelm? Thanks – Eric Brown - Cal Mar 30 '15 at 15:33
  • 1
    I suppose that `grid.addons.js` could be the origin of your problem, but I can't be sure if I don't know **which version of jqGrid you use?**. The file `grid.addons.js` contains **redefinition** of `searchGrid` and it can make many problems. You should not use it. Other remarks are common. I just don't recommend you to use such old versions *in any project* if you allows modern wen browsers open the web site. Holding of old versions you can get you much more problems as the usage of more recent versions which I mention before. – Oleg Mar 30 '15 at 15:39
  • Sadly we're intranet only and locked on ie 8 for the near and medium future.. I'd love to get it all up to date also... but the apps so big and the team so small they are holding us back. I checkd we are using JQGrid 4.0.0.. Is there a way to tell if grid.addon.js is being used other than removing it and exercising every branch of code on every page and see if it fails?Thanks – Eric Brown - Cal Mar 31 '15 at 16:53
  • **What methods exactly you use from `grid.addons.js` plugin?** I would recommend you to drop it. By the way I use in one my project jQuery 1.11.2, jQuery UI 1.10.4 and free jqGrid 4.8 and all seems to work under IE8. You can try to open the demos included on the bottom of [the readme](https://github.com/free-jqgrid/jqGrid/blob/master/README.md). Do you have some problem with the demos it you start there under IE8? I think that the latest jQuery UI 1.11.4 still support IE8 too. The main problem which you have: if you will find some bug somewhere, nobody will fix it in jqGrid 4.0.0/jQuery 1.4.2. – Oleg Mar 31 '15 at 17:37

1 Answers1

0

I really don't like this answer, but what i had to do to get it working was take the js file with the problem out of the bundle(and all that depend on it) and inject them normally.

it was painful testing it too... basically a full regression of the application, but it did work.

Eric Brown - Cal
  • 14,135
  • 12
  • 58
  • 97