Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any BundleTransformer JS minifiers that support ES6?

Are there any JS minifiers for BundleTransformer that support EcmaScript 6? I have tried installing:

  • BundleTransformer.Closure
  • BundleTransformer.YUI
  • BundleTransformer.UglifyJs

But neither seem to handle the string template syntax of ES6, such as:

`Hello ${world}`

Am I missing something, or is it time to upgrade to Node + X?

like image 780
Tormod Haugene Avatar asked Jun 06 '16 06:06

Tormod Haugene


1 Answers

Tormod!

Suppose you have the following code:

var world = 123;
alert(`Hello ${world}`);

Only two minifiers from the Bundle Transformer can process it:

  1. MicrosoftAjaxJsMinifier from BundleTransformer.MicrosoftAjax. It just minify a ES6 code.
  2. ClosureLocalJsMinifier from BundleTransformer.Closure with the following configuration settings:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      …
      <bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">
        …
        <closure>
          <js>
            …
            <local closureCompilerApplicationPath="…"
              javaVirtualMachinePath="…"
              languageInput="EcmaScript6" languageOutput="EcmaScript3" />
            …
          </js>
        </closure>
        …
      </bundleTransformer>
      …
    </configuration>
    

The transpilation from ES6 to ES3 will be made, and then the ES3 code will be minified. In addition, to the languageOutput attribute can be set the following values: EcmaScript5 and EcmaScript5Strict.

like image 110
Andrey Taritsyn Avatar answered Oct 28 '22 06:10

Andrey Taritsyn