Does it support minifying async/await ?
szilardd opened this issue · 4 comments
I'm using your solution described here: https://stackoverflow.com/questions/37650968/are-there-any-bundletransformer-js-minifiers-that-support-es6
But If I add this to a JS file
async function test() { }
Getting this error
Message: Expected ';'
Error code: JS1004
Severity: 0
Subcategory: run-time
File: /js/main.js
Start line: 1
Start column: 6
End line: 1
End column: 6
thanks
Hello, David!
This error occurs, because the Microsoft Ajax Minifier does not fully support ECMAScript 6 standard. Unfortunately, Microsoft Ajax Minifier library has not been developing since 2015.
To solve your problem, I recommend you to do the following:
- Install and configure the BundleTransformer.TypeScript module.
- Rename the
*.js
file, which is written in ECMAScript 6, into the*.ts
. - Add to the
Web.config
file the following settings:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
…
<bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">
…
<typeScript target="EcmaScript5" transpileOnly="true">
…
</typeScript>
…
</bundleTransformer>
…
</configuration>
P.S.: When I have free time, I will make a module based on the NUglify.
Thanks
I'm not able to rename *.js files to *.ts but it looks like a good approach for a new project.
Main things for me are bundling and cache busting.
So I ended up disabling minification like this. Not sure if it's the best way but it works:
var bundle = new CustomScriptBundle("MyBundleName");
bundle.Include(virtualPaths); // array of paths
// disable minification because it doesn't have support for ES6
var minifier = new NullMinifier();
var transformer = new ScriptTransformer(minifier);
bundle.Transforms.Clear();
bundle.Transforms.Add(transformer);
By the way, async/await
appeared in ES2017, but not in ES6 (ES2015). In this case, even the module based on the NUglify will not help.
Hello, David!
Try replacing the BundleTransformer.MicrosoftAjax module with the BundleTransformer.NUglify module.