BundlerMinifier icon indicating copy to clipboard operation
BundlerMinifier copied to clipboard

Minification not generating the file correctly when BigInt is involved

Open sapnc opened this issue 1 year ago • 2 comments

Installed product versions

  • Visual Studio: 2022.
  • This extension: 2.9.9

Description

The Minifier not generating the script when BigInt() method is used with a higher values.

Steps to recreate

Adding a sample code. The intention of this code is to check if the given string is well within the C# Int64 range. let TryParseLong = function (str, defaultValue) { var retValue = defaultValue; if (str !== null) { if (str.length > 0 && str.length <= 19) { if (!isNaN(str)) { if (BigInt(str) < BigInt("9223372036854775807")) { //Int64.MaxValue is "9223372036854775807" retValue = BigInt(str); } console.log(retValue); } } }

return retValue;

}

Current behavior

The minifier generates the minification file However the BigInt("9223372036854775807") gets generated as -9223372036854775808n

The minified code generated on the machine is let TryParseLong=function(n,t){var i=t;return n!==null&&n.length>0&&n.length<=19&&(isNaN(n)||(BigInt(n)<-9223372036854775808n&&(i=BigInt(n)),console.log(i))),i},a=123456,b=TryParseLong(a,-1);alert(b);

Expected behavior

Ideally it should stay as 9223372036854775808n

let TryParseLong=function(n,t){var i=t;return n!==null&&n.length>0&&n.length<=19&&(isNaN(n)||(BigInt(n)<9223372036854775808n&&(i=BigInt(n)),console.log(i))),i},a=123456,b=TryParseLong(a,-1);alert(b);

sapnc avatar Mar 21 '24 17:03 sapnc

Is this supported by NUglify?

failwyn avatar Apr 03 '24 12:04 failwyn

This is caused by targeting .Net 3.5 in NUglify; if you use BigInt("9007199254740991") for your comparison, it works correctly; if you aren't expecting numbers to be larger than that.

https://github.com/trullock/NUglify/issues/158

failwyn avatar Aug 01 '24 17:08 failwyn