2

I am using BundleTransformer for bundling the css and javascript. This is working fine with my Sitecore 9.3's MVC solution. I just upgraded sitecore to 10.3 and deployed the managed code. There is an runtime error as shown below.

Could not find a factory, that creates an instance of the JavaScript engine with name `ChakraCoreJsEngine`.
Description: An unhandled exception occurred.

Exception Details: JavaScriptEngineSwitcher.Core.JsEngineNotFoundException: Could not find a factory, that creates an instance of the JavaScript engine with name `ChakraCoreJsEngine`.

Source Error:

Line 24: <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
Line 25: 
Line 26: @Styles.Render("~/bundles/myProj/css")
Line 27: @Scripts.Render("~/bundles/myProj/vendor")
Line 28: @if (Model != null)

Stack Trace:

[JsEngineNotFoundException: Could not find a factory, that creates an instance of the JavaScript engine with name `ChakraCoreJsEngine`.]
   JavaScriptEngineSwitcher.Core.JsEngineSwitcher.CreateEngine(String name) +159
   DartSassHost.SassCompiler.InitializeCompiler() +136
   DartSassHost.SassCompiler.InnerCompile(String content, Boolean indentedSyntax, String inputPath, String outputPath, String sourceMapPath, CompilationOptions options) +72
   DartSassHost.SassCompiler.Compile(String content, String inputPath, String outputPath, String sourceMapPath, CompilationOptions options) +123
   BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.InnerTranslate(IAsset asset, SassCompiler sassCompiler, Int32 severity, Boolean enableNativeMinification) +228

[AssetTranslationException: During translation of SCSS code, readed from the file '/Areas/myProj/Assets/stylesheets/main.scss', to CSS code error has occurred.

I am using the below nuget packages and versions

  • BundleTransformer.Core 1.10.0.0
  • BundleTransformer.SassAndScss 1.13.13.0
  • DartSassHost 1.0.7.0

Also my web.config has the below.

<bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">
    <core>
      <css>
        <translators>
          <add name="NullTranslator" type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core" enabled="false" />
          <add name="SassAndScssTranslator" type="BundleTransformer.SassAndScss.Translators.SassAndScssTranslator, BundleTransformer.SassAndScss" />
        </translators>
        <postProcessors>
          <add name="UrlRewritingCssPostProcessor" type="BundleTransformer.Core.PostProcessors.UrlRewritingCssPostProcessor, BundleTransformer.Core" useInDebugMode="false" />
        </postProcessors>
        <minifiers>
          <add name="NullMinifier" type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core" />
        </minifiers>
        <fileExtensions>
          <add fileExtension=".css" assetTypeCode="Css" />
          <add fileExtension=".sass" assetTypeCode="Sass" />
          <add fileExtension=".scss" assetTypeCode="Scss" />
        </fileExtensions>
      </css>
      <js>
        <translators>
          <add name="NullTranslator" type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core" enabled="false" />
    </translators>
        <minifiers>
          <add name="NullMinifier" type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core" />
        </minifiers>
        <fileExtensions>
          <add fileExtension=".js" assetTypeCode="JavaScript" />
        </fileExtensions>
      </js>
    </core>
    <sassAndScss>
      <includePaths>
        <add path="~/Areas/myProj/Assets/stylesheets/vendor/bootstrap-sass/assets/stylesheets/bootstrap" />
        <add path="~/Areas/myProj/Assets/stylesheets/vendor/slick-carousel/slick" />
        <add path="~/Areas/myProj/Assets/stylesheets/vendor/font-awesome/scss" />
      </includePaths>
      <jsEngine name="ChakraCoreJsEngine" />
    </sassAndScss>
  </bundleTransformer>

So the JSEngine is ChakraCore. Thanks in advance for any ideas/solutions.

1 Answer 1

1

I am able to resolve this with the help of the Author @AndreyTaritsyn. You can find the answer below.

As far as I understand, you control contents of the App_Start/JsEngineSwitcherConfig.cs file yourself. Just change argument type of the Configure method to the IJsEngineSwitcher and you won't need type conversion.

To avoid the error described , you need to ensure that the JsEngineSwitcherConfig.Configure method is called before calling the BundleConfig.RegisterBundles method. As an example, you can look at the BundleTransformer.Sample.AspNet45.Mvc4 demo project (pay special attention to the App_Start/JsEngineSwitcherConfig.cs and Global.asax.cs files)."

More detailed thread in below link. https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/113

2
  • Please add solution details from the linked repository to your answer because links sometimes become unavailable and stop working. Commented Dec 18, 2023 at 7:38
  • 1
    @AnnaGevel I have answered in detail
    – Yeshwanth
    Commented Dec 19, 2023 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.