5

I have js files which I am using arrow function like the following:

$(document).ready(() => {});

And I am using System.Web.Optimization for bundling and minification in an MVC web application.

When I run my application it shows me the following error:

(9,20-21): run-time error js1195: expected expression: )

So, my question is there any way to configure my app to solve this issue?

Simple Code
  • 2,354
  • 2
  • 27
  • 56
  • `.ready(() => {});` is ambiguous JavaScript (is the callback returning an empty object-literal or is it a no-op braced function?). If this is not the cause of the error then please post your **actual* JavaScript. – Dai Sep 29 '20 at 11:00
  • But arrow function is a new feature in ES6 and it's not related to JQuery – Simple Code Sep 29 '20 at 11:04
  • 1
    Correct, it isn't related to jQuery - but I suspect that `System.Web.Optimization` only supports older ES3 (and maybe ES5?) language features [considering that System.Web.Optimization was released in 2013 and **hasn't been updated since 2014**](https://www.nuget.org/packages/Microsoft.AspNet.Web.Optimization/). I'd be wary of using any library or dependency for JavaScript that's more than a couple of years old. You should consider using `webpack` or Rollup instead. But anyway, jQuery is obsolete - it's been obsolete since IE11 came out in October 2013, imo. – Dai Sep 29 '20 at 11:06
  • Microsoft is still using System.Web.Optimization for bundling and minifying when generating MVC templates using Visual Studio :) – Simple Code Sep 29 '20 at 11:11
  • 2
    Only if you use the equally obsolete ASP.NET WebForms and ASP.NET MVC project templates. If you use the current ASP.NET Core project templates then you won't see references to `System.Web.Optimization`. – Dai Sep 29 '20 at 11:15
  • Does this answer your question? [Minification failed due to lambda expression](https://stackoverflow.com/questions/48513543/minification-failed-due-to-lambda-expression) – Frédéric Mar 16 '23 at 09:52
  • You may found alternatives [here](https://stackoverflow.com/q/28067798/1178314). – Frédéric Mar 16 '23 at 09:53

0 Answers0