trullock / NUglify

NUglify is a HTML, JavaScript and CSS minification Library for .NET (fork of AjaxMin + new features)
Other
396 stars 78 forks source link

Unable to minify js file if class contains method named import or export #403

Open mrzewnicki opened 3 months ago

mrzewnicki commented 3 months ago

Hi,

Problem occurs during minification of js file from external library. We are aware the import and export words are reserved keyword but we aren't able to change it in every new version of library files.

Code to reproduce:

var result = Uglify.Js(@"class bug {
    export() { console.log('omg'); }
    import() { console.log('omg'); }
}");
Console.WriteLine(result.HasErrors);
Console.WriteLine(result.Code);
Console.WriteLine(string.Join(", ", result.Errors.Select(e => e.Message)));
Console.ReadLine();

Result:

True
class bug{export(){console.log("omg")}import(){console.log("omg")}}
Expected identifier: export, Expected identifier: import
trullock commented 3 months ago

Looks like it doesnt support overwriding the export and import keywords. should be a simple fix