2

I've read most of the questions here on the same topic but none of them was solving my case.

So basically we are trying to bundle and minify the AngularJs files inside the .Net code. This is the code we are using to bundle our files inside the BundleConfig.cs

bundles.Add(new ScriptBundle("~/bundles/js/spa").IncludeDirectory(
                "~/App", "*.js", true
));
...
...
BundleTable.EnableOptimizations = true;

And in the browser, this is the error we are seeing with lots of errors that don't make sense - missing semicolumns when they are actually there, run-time error when everything is fine, etc.

/* Minification failed. Returning unminified contents.
(1746,27-35): run-time error JS1006: Expected ')': function
(1746,42): run-time error JS1004: Expected ';'
(1751,57): run-time error JS1004: Expected ';'
....
....

enter image description here

I don't really know where to search for the problem? Is it the .Net bundler or the JS code? Moving the minification inside the angularjs code is not an option.

.Net framework version: 4.7. AngularJs version: "angular": "^1.8.0"

Thank you in advance!

1 Answer 1

2

So apparently the ASP.Net bundler does not understand ES6 syntax. This means that you will get errors if your .js files contain ES6 syntax.

There are a few possible solutions to this problem:

  • Move the whole bundle/minify logic entirely on the front end application
  • Transpile the code to Vanilla JavaScript and then run it through the ASP.Net bundler
Sign up to request clarification or add additional context in comments.

1 Comment

Ugh, thanks for posting this. I'd be curious to know more details about what approach you've decided on. Have tried Webpack or Rollup, as suggesting in stackoverflow.com/q/64118160/2055511?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.