6

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?

Tormod Haugene
  • 3,538
  • 2
  • 29
  • 47
  • 1
    For those of you who want to close this for being Off Topic: I would not have asked this here unless I hadn't already looked into various online resources. If you really think it is off topic, let me know why. If you don't, I will have to ask the question over again. – Tormod Haugene Jun 06 '16 at 08:04

1 Answers1

2

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.

Andrey Taritsyn
  • 1,286
  • 11
  • 26
  • I've tried with BundleTransformer.MicrosoftAjax and `alert('Hello ${world}`); but I'm getting these errors generated. Any tips ? /* Minification failed. Returning unminified contents. (1,1579-1580): run-time error JS1014: Invalid character: ` (1,1586-1587): run-time error JS1193: Expected ',' or ')': $ (1,1593-1594): run-time error JS1002: Syntax error: } (1,1594-1595): run-time error JS1014: Invalid character: ` (1,1624-1625): run-time error JS1195: Expected expression: ) (1,1625-1626): run-time error JS1004: Expected ';': { */ – SzilardD Jun 26 '18 at 09:00
  • 1
    @SzilardD Try installing a new module - [BundleTransformer.NUglify](https://www.nuget.org/packages/BundleTransformer.NUglify). – Andrey Taritsyn Oct 02 '18 at 17:56