Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minify Error with async await #311

Closed
blogcraft opened this issue Nov 27, 2017 · 31 comments
Closed

Minify Error with async await #311

blogcraft opened this issue Nov 27, 2017 · 31 comments
Labels
Nuglify Issue originates in NUglify, waiting on fix there

Comments

@blogcraft
Copy link

Installed product versions

  • Visual Studio: 2017 Comunity Edition (15.4.4)
  • This extension: Bundler & Minifier 2.5.359 (Latest version of Extension available in VS Marketplace)

Description

Error:

(Bundler & Minifier) Expected ';'

When minifing a java script file with async and await keywords, finds error.

original unminified file works as expected in web browsers.

Steps to recreate

  1. Create new js file
  2. write any function with async await

example:

async function someName() {
    const response = await fetch('../some/URL');
    return await  response.json();
}

Current behavior

Error appears and wont minify

Expected behavior

Should minify

@alexanderkozlenko
Copy link
Contributor

It seems the root cause of the problem is the absence of async / await support in NUglify package which is used for JavaScript code minification. And thus, the issue should be raised on NUglify project firstly.

@bastienJS
Copy link

Done! trullock/NUglify#39

I experienced it yesterday too ;-)

@rockstardev
Copy link
Collaborator

Seems like we have bunch of ES6 errors... any volunteers for tackling this issue?

@rockstardev rockstardev added the Nuglify Issue originates in NUglify, waiting on fix there label May 8, 2018
@brightertools
Copy link

brightertools commented Jul 22, 2018

I am using bundler & minified with .net core 2.1 and vue.js and just added async functions, and the file is now has errors when processing in the Task Runner Explorer, I have the latest version, should this now work or is this an issue that still needs to be resolved? Do we need to not minify the file in the meantime?

@veikkoeeva
Copy link

I just came across this. Maybe worth trying https://github.com/Shazwazza/Smidge/, which use Nuglify too, though I haven't checked to which operations (publicly stated are source maps).

@brightertools
Copy link

Does anyone know if the issue is purely waiting for Nuglify? and has anyone used Smidge?

@brightertools
Copy link

Given this comment by the owner, it seems Nuglify is somewhat no longer actively maintained:
trullock/NUglify#55 (comment)

But hopefully any pull requests in the near future might fix the issue. Not sure if this is also actively maintained, but would be great if its was updated when Nuglify is updated or is updated to use another library that is maintained.

Bundler & minified is great, but since starting to use async functions, its difficult to know if we need to try and move to something else or wait for a fix?

@veikkoeeva
Copy link

If one is on .NET (and Razor) and uses TypeScript and on CSS3 (+ Grid etc.) to target whatever target, then using something from Nuget instead of WebPack might make sense. That's because there may not be a need to pull in something like Bootstrap and a SPA framework. Even more so in the future when Web Components and/or projects like lit-html/hyperHTML are more common.

Some rationale to the casual lurker for the reasons these might feel important.

@brightertools
Copy link

@veikkoeeva : What does that mean?

@brightertools
Copy link

Hi @blogcraft I just realised this issue is 9 months old, are you still waiting for a fix or have you found another solution? Thanks.

@CheloXL
Copy link

CheloXL commented Nov 23, 2018

Version 1.5.12 of NUglify added support for async/await... I tried to download BundlerMinifier to create a pull request, but I were unable to even compile the project...
Maybe someone can update Uglify and create a new version?

@data-handler
Copy link

Thank you for the update. Will you be updating the NuGet package also?

@mahop-net
Copy link

Will this update make it into the Visual Studio Extention?

@ndenkha
Copy link

ndenkha commented May 15, 2019

This issue still exists with the latest version 2.9.408, I have async on a class as follows and the async doesn't get minified. Please advise.

class UserConfig {

constructor() { }

async getUserStuff(userId) {
    let userStuff = await $.get(`/UserConfig/GetUserStuff?userId=${userId}`);
    return userStuff;
}

}

@shadowkras
Copy link

Also facing this issue, using version 0.5.7 of Bundle&Minifier.

@ndenkha
Copy link

ndenkha commented Jun 12, 2019

What we ended up doing is removing the await from any HTTP method calls, since the wire trip on the Controller side is async, it seems to work. e.g.

async getUserStuff(userId) {
let userStuff = $.get(/UserConfig/GetUserStuff?userId=${userId});
return userStuff;
}

@shadowkras
Copy link

Yep, also had to do the same to get the errors to stop.

@Gruski
Copy link

Gruski commented Aug 6, 2019

Is this planned to be fixed sometime soon?

@maurocordovaf
Copy link

I'm also facing this issue, is there any plan to fix it?

Thanks in advance.

@TheMadKow
Copy link

Same issue here. Any due date for that ?

@bardkalbakk
Copy link

Still an issue with the latest 3.2.435 release

@saisha-schwarzenbach
Copy link

This is still an issue. Any update?

@lucaswalter
Copy link

Also seeing this still as an issue

@drmathias
Copy link

It seems that the extension is no longer supported as it is still at v2.8.396. If you disable the extension and use the package, the issue is fixed.

@programad
Copy link

programad commented Oct 24, 2020

I think this bug has returned. I am building today in october 24 2020 and the error is the same.

@Gruski
Copy link

Gruski commented Oct 25, 2020

Same here. It never worked for me.

@aderrose
Copy link
Contributor

Just found the same issue and found a different workaround.

The version of BundlerMinifier published on VS Marketplace (2.8.396) is very old and last updated on 24/08/2018 but there is a nightly build published on Open VSIX Gallery (3.2.457) which was updated 2 months ago and works with the async await issue reported here.

It's a manual download from https://www.vsixgallery.com/extension/a0ae318b-4f07-4f71-93cb-f21d3f03c6d3/.

Hope this helps folks struggling with ES6 JavaScript not minifying properly.

@Gruski
Copy link

Gruski commented Feb 19, 2021

Still doesn't support basic ES6 constructs. See: #537

@chalcrow
Copy link

The latest version of the BuildBundleMinifier nuget package 3.2.449 (from Mads Kristensen) - seems to fix this. Available via Nuget Package Manager in Visual Studio.

@Gruski
Copy link

Gruski commented Apr 20, 2021

The latest version of the BuildBundleMinifier nuget package 3.2.449 (from Mads Kristensen) - seems to fix this. Available via Nuget Package Manager in Visual Studio.

Yes some of the ES6 issues have been addressed like the Async/Await but there are still issues with classes as shown here #537

@ndenkha
Copy link

ndenkha commented Apr 25, 2021

I installed the latest BuildBundleMinifier nuget package, but it kept giving lots of JS errors "bundler & Minifier error 0: Strict-mode does not allow assignment to undefined variables:...." against the minified files complaining about undefined variables where in reality the variables are defined. I couldn't get around this so I had to uninstall it.

Any help how to correct this behaviour will be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Nuglify Issue originates in NUglify, waiting on fix there
Projects
None yet
Development

No branches or pull requests