KryzhanovskyCssMinifier doesn't work with MsieJsEngine but does with V8JsEngine

289 Views Asked by At

I am using the latest BundleTransformer for ASP.NET.

I have an extremely simple bundle file with one LESS file:

 var cssBundle = new CustomStyleBundle("~/Content/css/bundle").Include(                                              
                                       "~/Content/css/test.less");
 bundles.Add(cssBundle);

The LESS file I've made as simple as possible to prove it is actually correctly interpreting as LESS.

.something
{
    ol, ul
    {
        list-style: none;
    }
}

When I try to use V8JsEngine it works as expected (relevant web.config shown):

<css defaultMinifier="KryzhanovskyCssMinifier" usePreMinifiedFiles="false">
    <minifiers>
         <add name="KryzhanovskyCssMinifier" type="BundleTransformer.Csso.Minifiers.KryzhanovskyCssMinifier, BundleTransformer.Csso" />
    </minifiers>
</css>

<csso>
  <css disableRestructuring="false" />
  <jsEngine name="V8JsEngine" />
</csso>

This gives me the correct CSS:

.something ol,.something ul{list-style:none}

However when I switch to MsieJSEngine

<csso>
  <css disableRestructuring="false" />
  <jsEngine name="MsieJsEngine" />
</csso>

I get the following bizarrely incorrect CSS - with UL completely stripped out.

.something ol{list-style:none}

I just can't quite fathom how this is even possible. It has been interpreted correctly as LESS, but completely stripped out the UL from the list. Incidentally if I make it just a pure css file without the .something class I get the same incorrect result.

Fortunately it seems to work fine with V8JsEngine so I can keep on, but I'm posting this here hopefully to help others and because I'm very curious if there's something I did wrong.


File versions:

BundleTransformer.Core - 1.9.3.0
BundleTransformer.Csso - 1.9.1.0
BundleTransformer.Less - 1.9.1.0
BundleTransformer.MicrosoftAjax - 1.9.1.0
1

There are 1 best solutions below

1
On

For BundleTransformer.Csso need the full support of ECMAScript 5, that is implemented only in ChakraJsRt mode of the MSIE JavaScript Engine for .NET. Quote from the documentation:

JsRT version of Chakra JavaScript engine (supports ECMAScript 5). Requires Internet Explorer 11 or higher on the machine.

Incidentally, in description of the BundleTransformer.Csso NuGet-package has the following requirement:

For correct working of this module is recommended to install the following NuGet packages: JavaScriptEngineSwitcher.V8 or JavaScriptEngineSwitcher.Msie (only in the ChakraJsRt mode).