'Why does ES6 JavaScript run locally from VS and not from same browser after deployed to server
I have built a .NET Core application with VS2019. In the application's JS files, I have used the let keyword in a few places. Example let x = 2 When debugging I have VS set to run the version of Chrome installed on my desktop (using file.js) and all works well. Once I deploy the application to a server (and use file.min.js), the browser no longer recognizes the let keyword.
Any idea why using the same browser, it down grades to ES5 when deployed, yet runs ES6 correctly locally?
Update:
To recreate this issue use the Market Place extension BundlerMinifier
When minifying the following code, variables of the same name are used in the transformation that leads to bugs in the JavaScript minimized file.
Within a .js file create an ajax call to retrieve some data. upon success of data retrieval, loop through an array from within the returned value.
Use this language for the loop for(let accts of data.accounts)
Current behavior:for(let accts of data.accounts) minimizes into for(let t of t)
Both the variable and the array property end up with the same name.
Expected behaviorfor(let accts of data.accounts) minimizes into for(let a of b)
The variable and property should have different names
Solution 1:[1]
I believe I have found the answer to my own question.
It seems a bug may be present in the code of the minimize plug in I am using.
I have created a bug issue in the GitHub repository that can be found here: Issue with minimize transforming to object to the same name #580
In short, the true issue was not with the let keyword, but that the variable it was calling had the same name as another within the same scope.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | JStevens |
