Upgrade JSS apps to JSS 22.1
Sitecore JavaScript Rendering SDK version 22.1 requires you to make some modifications to your apps.
-
If you haven't already done so, upgrade your app to JSS 22.0.
-
Familiarize yourself with the JSS 22.1 release notes to ensure you understand the implications of upgrading.
This topic describes how to:
To update your JSS Next.js applications, follow the detailed upgrade guide from JSS 22.0.0 to 22.1 for JSS Next.js apps instead of this topic.
Replace the import path for editing utilities (all frameworks)
We're moving all editing utilities located at @sitecore-jss/sitecore-jss/utils to the more meaningful @sitecore-jss/sitecore-jss/editing. As a result, you will need to replace the path of any import statements in your code that refer to the older location.
This change affects the following utilities:
-
ChromeCommand -
DefaultEditFrameButton -
DefaultEditFrameButtonIds -
DefaultEditFrameButtons -
EditButtonTypes -
EditFrameDataSource -
ExperienceEditor -
FieldEditButton -
handleEditorAnchors -
HorizonEditor -
isEditorActive -
mapButtonToCommand -
Metadata -
resetEditorChromes -
WebEditButton
The older path will only continue to work until the next release of JSS. Therefore, we strongly recommend you make the necessary changes as soon as possible.
Update Angular apps
Some of the steps in this section repeat the upgrade guide for JSS 21.8. Therefore, if you've already applied those changes, you do not need to repeat them here.
To update your Angular applications:
-
Update TypeScript to
~5.2.2. -
Update Angular and all of its core dependencies to version 17, along with any related dependencies. The following list shows the required versions at time of release:
-
Angular main dependencies:
RequestResponse"@angular/animations": "~17.3.11", "@angular/common": "~17.3.11", "@angular/compiler": "~17.3.11", "@angular/core": "~17.3.11", "@angular/forms": "~17.3.11", "@angular/platform-browser": "~17.3.11", "@angular/platform-browser-dynamic": "~17.3.11", "@angular/platform-server": "~17.3.11", "@angular/router": "~17.3.11", -
Angular dev dependencies:
RequestResponse"@angular-builders/custom-webpack": "^17.0.2", "@angular-devkit/build-angular": "^17.3.8", "@angular-eslint/builder": "^17.5.2", "@angular-eslint/eslint-plugin": "^17.5.2", "@angular-eslint/eslint-plugin-template": "^17.5.2", "@angular-eslint/schematics": "^17.5.2", "@angular-eslint/template-parser": "^17.5.2", "@angular/cli": "~17.3.8", "@angular/compiler-cli": "~17.3.11", "@angular/language-service": "~17.3.11", -
Other main dependencies:
RequestResponse"@ngx-translate/core": "~15.0.0", "@ngx-translate/http-loader": "~8.0.0", "apollo-angular": "~6.0.0", "bootstrap": "^5.3.3", "core-js": "~3.37.1", "tslib": "^2.6.3", "zone.js" "~0.14.7", -
Other dev dependencies:
RequestResponse"@types/node": "~20.14.10", "@typescript-eslint/eslint-plugin": "^7.16.0", "@typescript-eslint/parser": "^7.16.0", "body-parser": "~1.20.2", "eslint": "^8.56.0", "eslint-plugin-import": "2.29.1", "eslint-plugin-jsdoc": "48.7.0", -
All remaining dependencies can be left at their current versions.
-
-
If you have not customized the
scripts/generate-config.tsfile, replace it with the 22.1 version. Otherwise, modify your file as follows:-
In the
configTextprop assignment, afterconfig[prop]?, add atoStringmethod call followed by atrimmethod call, such as:RequestResponseconfig[prop]?.toString().trim() -
At the end of that assignment, replace the comma before the newline character with a semicolon:
RequestResponse// Before }",\n`; // After }";\n`;
Here's an example of the updated assignment suitable for JSS 22.1:
RequestResponseconfigText += `config.${prop} = process.env.${constantCase(prop)} || "${config[prop]?.toString().trim()}";\n`; -
-
Also in the
scripts/generate-config.jsfile, repeat step 3 forcomputedConfig[prop]. Here's an example of the updated assignment suitable for JSS 22.1:RequestResponseconfigText += `config.${prop} = process.env.${constantCase(prop)} || ${ computedConfig[prop]?.toString().trim() };\n`; -
If you have not customized the
/server.bundle.tsfile, replace it with the 22.1 version. Otherwise, modify your file as follows:-
Locate the following
importstatement:RequestResponseimport 'zone.js/dist/zone-node'; -
Replace that statement with the following:
RequestResponseimport 'zone.js';
-
-
If you have not customized the
src/polyfills.tsfile, replace it with the 22.1 version. Otherwise, modify your file as follows:-
Locate and remove the following
importstatements, if present:RequestResponseimport 'zone.js/dist/zone-node'; import 'zone.js/dist/zone'; -
Add a new
importstatement as follows:RequestResponseimport 'zone.js';
-
-
If you have not customized the
src/test.tsfile, replace it with the 22.1 version. Otherwise, modify your file as follows:-
Locate and remove any
importstatements containingzone.js/dist. -
Add a new
importstatement as follows:RequestResponseimport 'zone.js/testing';
-
-
If your existing app has other customizations that might be affected by the Angular 17 upgrade, refer to the Angular 17 upgrade guide for guidance on what further changes are required.
-
Update your application's JSS package, and install dependencies.
Update React apps
The simplification of editing support has introduced a new breaking change to the sitecore-jss-react package that requires you to make some modifications to your apps.
To update your React applications:
-
Because
ComponentConsumerPropshas been removed, if you have anyimportstatements that reference it, update them all to useWithSitecoreContextPropsinstead. -
If you have not customized the
scripts/generate-config.jsfile, replace it with the 22.1 version. Otherwise, modify your file as follows:-
In the
configTextprop assignment, add atrimmethod call afterconfig[prop]?, such as:RequestResponseconfig[prop]?.trim() -
At the end of that assignment, replace the comma before the newline character with a semicolon:
RequestResponse// Before }",\n`; // After }";\n`;
Here's an example of the updated assignment suitable for JSS 22.1:
RequestResponseconfigText += `config.${prop} = process.env.REACT_APP_${constantCase(prop)} || "${ config[prop]?.trim() }";\n`; -
-
Update your application's JSS package, and install dependencies.
Update Vue.js apps
To update your Vue.js applications:
-
If you have not customized the
scripts/generate-config.jsfile, replace it with the 22.1 version. Otherwise, modify your file as follows:-
In the
configTextprop assignment, add atrimmethod call afterconfig[prop]?, such as:RequestResponseconfig[prop]?.toString().trim() -
At the end of that assignment, replace the comma before the newline character with a semicolon:
RequestResponse// Before }",\n`; // After }";\n`;
Here's an example of the updated assignment suitable for JSS 22.1:
RequestResponseconfigText += `config.${prop} = process.env.VUE_APP_${constantCase(prop)} || "${ config[prop]?.trim() }";\n`; -
-
Also in the
scripts/generate-config.jsfile, repeat step 1 forcomputedConfig[prop]. Here's an example of the updated assignment suitable for JSS 22.1:RequestResponseconfigText += `config.${prop} = process.env.VUE_APP_${constantCase(prop)} || ${ computedConfig[prop]?.trim() };\n`; -
Update your application's JSS package, and install dependencies.
Update application dependencies
For your upgraded applications to work correctly, you must update dependencies.
To update your dependencies:
-
In your existing application's
package.jsonfile, update every@sitecore-jsspackage to version~22.1. -
Install the dependencies with the following command:
RequestResponsenpm install