Using the latest version of MVC4 I can\'t minify javascript when it contains reserved words as key names!
See the error below with the valid javascript that should h
Hope it's not too late. You can implement own minification transform and ignore these errors.
var bundle = new ScriptBundle("~/bundles/xxxbundle", null, new JsMinifyIgnoreReservedWordError()).
Include("~/Scripts/xxx.js");
private class JsMinifyIgnoreReservedWordError : IBundleTransform
{
private const string JsContentType = "text/javascript";
public void Process(BundleContext context, BundleResponse response)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
if (response == null)
{
throw new ArgumentNullException("response");
}
if (!context.EnableInstrumentation)
{
Minifier minifier = new Minifier();
string result = minifier.MinifyJavaScript(response.Content, new CodeSettings
{
EvalTreatment = EvalTreatment.MakeImmediateSafe,
PreserveImportantComments = false,
IgnoreErrorList = "JS1137" // ignore 'is a new reserved word and should not be used as an identifier' error
});
if (minifier.ErrorList.Count > 0)
{
GenerateErrorResponse(response, minifier.ErrorList);
}
else
{
response.Content = result;
}
}
response.ContentType = JsContentType;
}
private static void GenerateErrorResponse(BundleResponse bundle, IEnumerable