0

We have recently upgraded to Angular 15 for Sitecore. Everything works fine except for the Experience Editor. We are getting the following. I am suspicious that Sitecore is not fully ready for Angular 15? Thanks in advance.

Error Rendering Sitecore.JavaScriptServices.ViewEngine.Presentation.JsLayoutRenderer: ES Modules may not assign module.exports or exports.*, 
   Use ESM export syntax, instead: 99534 Error: ES Modules may not assign module.exports or exports.*, 
   Use ESM export syntax, instead: 99534 
      at Object.set [as exports] (C:\inetpub\wwwroot\dist\EmployerAdminPortal\server.bundle.js:14:6392553) 
      at 99534 (C:\inetpub\wwwroot\dist\EmployerAdminPortal\server.bundle.js:14:2878721) 
      at __webpack_require__ (C:\inetpub\wwwroot\dist\EmployerAdminPortal\server.bundle.js:14:6391825) 
      at C:\inetpub\wwwroot\dist\EmployerAdminPortal\server.bundle.js:14:6393006 
      at Object. (C:\inetpub\wwwroot\dist\EmployerAdminPortal\server.bundle.js:14:6393258) 
      at Module._compile (node:internal/modules/cjs/loader:1159:14) 
      at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) 
      at Module.load (node:internal/modules/cjs/loader:1037:32) 
      at Module._load (node:internal/modules/cjs/loader:878:12) 
      at Module.require (node:internal/modules/cjs/loader:1061:19)
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.HostingModels.Http.HttpNodeInstance.InvokeExport[T](NodeInvocationInfo invocationInfo)
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.HostingModels.OutOfProcessNodeInstance.InvokeExport[T](String moduleName, String exportNameOrNull, Object[] args)
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.DefaultNodeServices.InvokeExportWithPossibleRetry[T](String moduleName, String exportedFunctionName, Object[] args, Boolean allowRetry)
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.DefaultNodeServices.InvokeExport[T](String moduleName, String exportedFunctionName, Object[] args)
   at Sitecore.JavaScriptServices.ViewEngine.Node.NodeRenderEngine.Invoke[T](String moduleName, String functionName, Object[] functionArgs)
   at Sitecore.JavaScriptServices.ViewEngine.Presentation.JssRenderer.PerformRender(TextWriter writer, IRenderEngine renderEngine, String moduleName, String functionName, Object[] functionArgs)
   at Sitecore.JavaScriptServices.ViewEngine.Presentation.JssRenderer.Render(TextWriter writer)
   at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)
2
  • What JSS version are you on?
    – Richard Seal
    Commented Oct 11, 2023 at 19:10
  • @RichardSeal "@sitecore-jss/sitecore-jss-angular": "21.3.1", Commented Oct 11, 2023 at 20:53

3 Answers 3

0

You need to be on at least JSS v21.3.0, this was when Angular 15 support was added:

https://github.com/Sitecore/jss/blob/v21.3.0/packages/sitecore-jss-angular/package.json

For that, you would also need to make sure your XP/XM instance is at least 10.3.0 based on the compatibility table: https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB1000576

2
  • We are indeed on this version and the only thing that seems to be "busted" is the experience editor. I will check about the XP/XM instance. Commented Oct 11, 2023 at 20:37
  • the XM instance is SITECORE_VERSION=10.3-ltsc2019 Commented Oct 11, 2023 at 20:59
0

For clarity, this error message indicates a mismatch in module export syntax between ES Modules (ESM) and CommonJS. Specifically, there is an attempt to use CommonJS module export syntax within an ES module.

First I would ask how the Angular upgrade was decided on prior to checking JSS compatibility. When it comes to Sitecore compatibility, it's almost always better to start with JSS as the basis for version compatibility and then go from there, rather than treating your custom code as the basis for version compatibility and trying to make it work with incompatible versions of JSS (trying to be the "tail that wags the dog").

Aside from @Richard Seal's answer to upgrade your version of JSS, some other (ostensibly less desirable) options are:

  • Downgrade back to Angular 12
  • Fiddle with your webpack configuration to handle ESM
  • Inspect the changes in the sitecore-jss-angular lib that Richard linked to and selectively add support for Angular 15 wherever necessary
2
  • Thank you I will look into this. Sitecore stated that they were ready for angular 15 and we wanted to start using standalone components. This was the reason for the upgrade. We were recently on 14. Commented Oct 11, 2023 at 20:35
  • Could you possibly guide me to "Fiddle with your webpack configuration to handle ESM"? Commented Oct 11, 2023 at 21:01
0

The problem was in the Sitecore server.bundle.ts file. In previous versions of Angular there was:

module.exports = {...}

In the new version, now it's just:

export {...}

-Judson

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.