1

I have a .NET MVC application, for which I use the (2022 version of the) WebCompiler extension for Visual Studio 2022, in order to minify my CSS et JS files.

When the JS scripts get minified, it seems like the extension is adding some undesired pieces of code to the resulting script. Things like :

function _toConsumableArray(n){if(Array.isArray(n)){for(...

Or even :

return regeneratorRuntime.async(function(o){for...

I'm assuming it does this because, for some random reason, it seems to beleive I'm using some kind of JS technology other than simple classic web JavaScript, like Node JS, Babel or whatever.

And this is causing issues on the client side obsiously, with errors like regeneratorRuntime not being defined.

Is there a way to prevent the extension from doing that ? Are there reserved keywords that can be used with other JS technologies that would make the extension beleive it's using that technology and that I should avoid using in my scripts ? Is there any other viable JS minifying extension that works with VS 2022 ? It seems like WebCompiler is discontinued.

I searched the compilerconfig.json.defaults file, but it doesn't seem to contain any option regarding this, nor does compilerconfig.json.

Virus721
  • 8,061
  • 12
  • 67
  • 123

1 Answers1

1

So I found out what was causing the regeneratorRuntime thing to appear, it was the use of the async/await keywords.

I removed the async from my function declaration, and used then() instead of await, and the regeneratorRuntime went away.

The _toConsumableArray thing is still there, probably caused by something else, but this one isn't causing any client side error, so I can live with it.

Virus721
  • 8,061
  • 12
  • 67
  • 123
  • Perhaps accept your answer to your own question here. – Mark Schultheiss Aug 10 '22 at 15:04
  • This started happening to me suddenly today and it's unrelated to async/await, I have also tried it with then() with the same result. The only way to stop it is by uninstalling the extension WebCompiler 2022+. – Ninos Mar 14 '23 at 18:49