Javascript error in *.min.js.map files

I’ve been getting an JavaScript error:

JavaScript critical error at line 2, column 14 in http://localhost:53885/Scripts/jquery.unobtrusive-ajax.min.js.map\n\nSCRIPT1004: Expected ‘;’

This has happened in a few different files, I tried regenerating the *.min.js and *.min.js.map files, but it just wouldn’t go away.

Eventually with a bit of searching Ifound the cause of the problem, Asp.Net MVC Bundles.

Our code was:

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
            "~/Scripts/jquery.unobtrusive*",
            "~/Scripts/jquery.validate*"
            ));

and we changed it to:

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
            "~/Scripts/jquery.unobtrusive-{version}.js",
            "~/Scripts/jquery.validate-{version}.js"
            ));

This stops the bundle loading the map files.

Advertisements