7

If you upgrade from version 1 to version 2 of BundleTransformer you may get this message:

Could not find a factory, that creates an instance of the JavaScript engine with name MsieJsEngine.

Like me, you may not even have realized you've upgraded more than just a point release.

How to fix?

Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689

2 Answers2

14

Version 2 DOES NOT USE WEB.CONFIG for configuration anymore

So start by removing it and read the rest of this link

https://github.com/Taritsyn/JavaScriptEngineSwitcher/wiki/How-to-upgrade-applications-to-version-2.X


Basically you will be doing the following:

  • Removing existing web.config nodes for javscript engine
  • Adding to someplace like global.asax some initialization code
  • Install Nuget packages for the engines you want to use
  • Make sure to add a using statement to be able to use extension methods (if you choose that way)

I ended up with something like this:

    using JavaScriptEngineSwitcher.Core;
    using JavaScriptEngineSwitcher.Msie;
    using JavaScriptEngineSwitcher.V8;

    ....

    public class JsEngineSwitcherConfig
    {
        public static void Configure(JsEngineSwitcher engineSwitcher)
        {
            engineSwitcher.EngineFactories
                .AddMsie(new MsieSettings
                {
                    UseEcmaScript5Polyfill = true,
                    UseJson2Library = true
                })
                .AddV8();

            engineSwitcher.DefaultEngineName = MsieJsEngine.EngineName;
        }
   }
Community
  • 1
  • 1
Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689
1

I'm following the instructions, but my code is now breaking on BundleConfig

var cssTransformer = new StyleTransformer();

In the name attribute of /configuration/bundleTransformer/less/jsEngine configuration element not specified a name of JavaScript engine.

If you have not installed JavaScript engine, then for correct working of this module is recommended to install one of the following NuGet packages: * JavaScriptEngineSwitcher.Msie * JavaScriptEngineSwitcher.V8 * JavaScriptEngineSwitcher.ChakraCore

After package is installed, need set a name of JavaScript engine (for example, MsieJsEngine) to the name attribute of /configuration/bundleTransformer/less/jsEngine configuration element.

Yovav
  • 2,557
  • 2
  • 32
  • 53