AEM as a Cloud Service deployment fails due to JavaScript optional chaining syntax errors

AEM as a Cloud Service pipeline deployments can fail when a JavaScript ClientLib uses optional chaining syntax that the ClientLib compiler does not support. Update or transpile the affected JavaScript code to a compatible ECMAScript version to resolve the failure.

Description description

Environment

Adobe Experience Manager (AEM) as a Cloud Service (all versions)

Symptoms

Deployments to any AEM Cloud environment via the pipeline may fail during the Update Indexes step. Pipeline logs display JavaScript ClientLib compilation errors indicating that optional chaining syntax (?.) is not supported. The following is an example of the error message and the offending code:

  • ERROR - [ JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2020 mode or better: Optional chaining.
  • [ generic-path] /clientlib.min.js: variable = object?.property?.subproperty

These errors are reproducible across multiple pipeline executions and are not transient.

Cause

The JavaScript ClientLib compiler is configured for ECMASCRIPT_2018, which does not support optional chaining syntax (?.). JavaScript files using this syntax must be updated or transpiled to a compatible version before compilation.

Resolution resolution

Follow these steps to resolve the issue:

  1. Review the pipeline logs to identify all JavaScript files that use optional chaining syntax (?.) and are failing during ClientLib compilation.
  2. Update the affected JavaScript code to use ECMASCRIPT_2018-compatible syntax, or ensure that all JavaScript code using optional chaining is transpiled (for example, using Babel) to ECMASCRIPT_2018 or earlier before being included in ClientLibs.
  3. Confirm that the ClientLib compiler configuration is set to ECMASCRIPT_2018. If updating the compiler configuration is not possible, code changes or transpilation are required.
  4. Rerun the AEM Cloud pipeline to deploy your code.
  5. Verify that the deployment succeeds. If failures persist, review the latest pipeline logs for new errors and continue troubleshooting as needed.
recommendation-more-help
experience-cloud-kcs-help-kbarticles