Option to ignore warnings per input file when using AjaxMinTask

Apr 24, 2013 at 5:29 AM
I'm trying to get AjaxMin setup in a project I'm working on (utilizing the AjaxMinTask via AjaxMinTask.targets) and here's my scenario:

Ideally, I would like to bundle every JS file in my project into one. This includes 3rd party libraries like knockout & jQuery. However, when including said 3rd party libraries, a bunch of warnings are logged (~800+ warnings). Of course, since the 3rd party libraries are out of my control, it makes no sense to go in and correct the libraries. Furthermore, I would like to enable TreatWarningsAsErrors, to prevent our interns from checking in warning-laden code.

Would it be possible to add property to <input /> tag in the manifest file such as the following:
<output path="Scripts/min/mylib.min.js" type="js" enc="utf-8">
    <input ignorewarnings="true" path="Scripts/lib/modernizr/modernizr-2.6.2.js" />
    <input ignorewarnings="true" path="Scripts/lib/bootstrap/bootstrap.js" />
    <input ignorewarnings="true" path="Scripts/lib/jquery/jquery-2.0.0.js" />
    <input path="Scripts/src/myfile1.js" />
    <input path="Scripts/scr/myfile2.js" />
Setting ignorewarnings to true (false by default), should suppress any warning messages received while processing that particular file.
Apr 24, 2013 at 4:06 PM
I like it! I'll see if I can add that for 4.90.
Apr 24, 2013 at 6:55 PM
Awesome! Thanks!
Apr 25, 2013 at 5:48 PM
Just FYI: turns out to be more difficult than it appears on the surface. The manifest is used to concatenate the input files and specifies the overall switches and output file to use on that combined input. It then hands off to the parser and visitors, which generate the warnings and don't really know what the manifest says about the various pieces-parts making up the combined input (right now). I think I have an idea on how to do this, though, but it might be further out than the 4.90 release, since I have a couple high-pri bugs that I need to get fixed and released first. But I still love the idea.
Apr 25, 2013 at 6:41 PM
Alright, not a problem at all, take your time. Thanks for looking into it!
May 6, 2013 at 7:02 PM
Okay, this will be in the 4.91 release. If you specify the attribute origin="external" on an <input> element of the manifest XML, all warnings will be suppressed while minifying that file (will still throw JavaScript syntax errors, but an external file shouldn't have any of those anyway).

One small ramification is that this could change the groupings of files concatenated together around any external file(s). Before this change, all input files were concatenated together and then the entire combination was minified to the output file - and that behavior will remain the same for any set of input files that contains no origin="external" attributes. After this change, external files will always be minified by themselves, independent of the other files in the group, and all adjacent project files (those not marked as "external") will be concatenated and minified together. Finally, the groups of concatenated input files will be concatenated together into the output file. For example, an output group that contains :
    <input path="file1.js"/>
    <input path="file2.js"/>
    <input path="file3.js"/>
    <input path="external1.js" origin="external" />
    <input path="external2.js" origin="external" />
    <input path="file4.js"/>
    <input path="file5.js"/>
will actually concatenate four sets of minified concatenated code into the output file: minify(file1.js+file2.js+file3.js) + minify(external1.js) + minify(external2.js) + minify(file4.js+file5.js). The order of the minified files in the output remains as specified in the order of the <input> elements; it's just that adding external input files to the mix creates different groupings that get independently minified as they are added to the output file. Those groups will be separated by a newline in the final output file.
May 6, 2013 at 7:42 PM
Perfect, that sounds like it'd work. I always make it a practice to include 3rd-party libraries first anyways, since our JS files depend on them.
May 8, 2013 at 12:10 AM
Just released 4.91. Let me know if you have any issues with it. I'll update the docs shortly.