Taritsyn / BundleTransformer

Bundle Transformer - a modular extension for System.Web.Optimization (also known as the Microsoft ASP.NET Web Optimization Framework).
Apache License 2.0
130 stars 19 forks source link

ES2017 support for UglifyJS #43

Closed ghost closed 3 years ago

ghost commented 3 years ago

The current version of UglifyJS (2.8.29) does not support ES2017 (await, async). The support start with UglifyJS 3.0.17. https://github.com/mishoo/UglifyJS/issues/1789

Is there any plan to support the newer version of UglifyJS ? Or any support of ES2017 with the other transformers ?

Taritsyn commented 3 years ago

Hello, Jules!

I recommend that you start using the BundleTransformer.NUglify module.

ghost commented 3 years ago

I have a similar issue NUglify.

I created a console app with NUglify and minified this script :

new Vue({
    data() {
        return {
            message: ''
        }
    }
});

The console app works

        static async Task Main(string[] args)
        {
            string js = await File.ReadAllTextAsync("./script.js");
            var result = Uglify.Js(js);

            Console.WriteLine(result.Code); // outputs new Vue({data(){return{message:""}}})
        }

The Bundler throws an error for the same script

Message: Implicit property name must be identifier: data() { return { message: '' }; } Error code: JS1314 Severity: 0 Subcategory: run-time File: /Scripts/vue.js Start line: 2 Start column: 5 End line: 6 End column: 6

Taritsyn commented 3 years ago

The console app works

You just don't process the Errors property from returned result.

Taritsyn commented 3 years ago

Try to add in the Web.config file the following setting:

<configuration>
  …
  <bundleTransformer …>
    …
    <nuglify>
      <js ignoreErrorList="JS1314" />
      …
    </nuglify>
    …
  </bundleTransformer>
  …
</configuration>
ghost commented 3 years ago

It is working. Thanks for the help.