Closed RudeySH closed 10 months ago
I did some more testing. Even with slightly more advanced usage of NUglify, by itself it is able to parse the JS just fine. Still can't get it to work with BundleTransfomer though.
var parser = new JSParser
{
Settings = new CodeSettings
{
StrictMode = true,
},
};
var result = parser.Parse(@"""use strict"";
var AchievementsDisplayMode;
(function (AchievementsDisplayMode) {
AchievementsDisplayMode[AchievementsDisplayMode[""All""] = 0] = ""All"";
AchievementsDisplayMode[AchievementsDisplayMode[""Unrestricted""] = 1] = ""Unrestricted"";
})(AchievementsDisplayMode || (AchievementsDisplayMode = {}));");
parser.CompilerError += (x, y) =>
{
// Success! This event never fires.
};
Hello, Rudey!
I can't reproduce this error using the default settings of the BundleTransformer.NUglify module. It is possible that you are using some other settings or old version of the BundleTransformer.NUglify module.
Try to reproduce this error in the form of demo project and send me a link to it.
While creating the demo project, I figured out what was wrong.
My bundle included a JS file that uses the enum before the enum JS file itself was included. Apparently this was never a problem while using the built-in ScriptBundle. I began using CustomScriptBundle and NullOrderer today, which is probably why this issue popped up. I solved the issue by including all enums before any other includes.
The
NUglifyJsMinifier
throws an error when it encounters a transpiled TypeScript enum.Example TypeScript enum:
This enum gets transpiled into: (at least when targeting ES2015)
When I run my application, I get the following exception:
NUglify itself seems to work fine:
How come NUglify is able to parse the JS without errors, while BundleTransformer throws an
NUglifyParsingException
?As a workaround you can disable strict mode, but that is not an acceptable solution.