I have an MVC bundle where one of the files is simply not being included in the output, even though it can be found properly. I am familiar with all the standard bundling rules (min
vs no min, .debug
vs .js
, etc), but this appears to have something to do with the contents of the file.
Edit: Configuration (should have included this to start with)
"Microsoft.AspNet.Web.Optimization
v1.0WebGrease
v1.1MVC Stuff
v4.0.20710.0
After some playing, I discovered that if I modify the file a little bit, it will be included in the output. If undo the change, then the entire file is simply not included in the output. Not garbled, corrupted, etc, simply not there.
The bundle looks like this:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery.unobtrusive*",
...
"~/Scripts/underscore/underscore.js",
"~/Scripts/underscore/underscore.string.js"
));
The problem is in underscore.string.min.js
. This file starts out like this (it is 1 line):
!function (e, t) { "use strict"; var n = t.prototype.trim, //...
I have found that if I make this change hen the undescore.string.min.js
file is included properly. Some changes, such as adding a comment, do not work. Adding a call to console.log("");
as the first line works too, but the actual call to console.log()
is ¿removed?
;
!function (e, t) { "use strict"; ....
- Placing the
;
on the first line doesn't work (;!function (e, t) {
) - Deleting the
.min.js
file and letting ASP.NET MVC works fine - What is that
!
there for anyway!
The file before it, underscore.min.js
, looks like this:
// Underscore may be freely distributed under the MIT license.
(function(){/* lots of code */}).call(this);
//# sourceMappingURL=underscore-min.m
And the final bundled minified output looks like this:
function"==typeof define&&define.amd&&define("underscore",[],function(){return n})}
.call(this),!function(n,t){"use strict";var a=t.prototype.trim,s=t.prototype.trimRight
This has all made me a little nervous to use any provided .min.js
files, since I am not quite sure what will fail and when. If it does fail, there is no notice or warning anywhere I can find that tells me something went wrong processing a particular file (e.g. it resulted in no output?). Am I better off just abandoning pre-minified assets?