- その他のフレームワーク
JSSアプリをJSS 22.0.0にアップグレードする
このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。
Sitecore JavaScript Rendering SDKバージョン22.0.0では、アプリの小さな修正が必要です。
!注始める前に
まだアップグレードしていなければ、アプリをJSS 21.7にアップグレードしてください。
すでにAngular 17対応のために21.8にアップグレードしている場合は、このガイドの手順を完了した後すぐに22.1にアップグレード し、Angular 17の互換性を維持する必要があります。
アップグレードの影響を理解するために、JSS 22.0.0のリリースノート に精通してください。
このトピックでは、以下の方法を説明します:
!注JSS Next.jsアプリケーションを更新するには、このトピックではなく、JSS 21.7から22.0.0への詳細なアップグレードガイド に従ってください。JSS Next.jsアプリの場合は。
Angularアプリのアップデート
!重要もしあなたのアプリが現在Angular 17でJSS 21.8を使用している場合、JSS 22.0にアップグレードした後はすぐに22.1にアップデートする必要があります。Angular 17のアップデートはバージョン22.1から21.8にバックポートされていますが、バージョン22.0には含まれていません。
AngularJSアプリケーションを更新するには:
-
JSS_APP_NAME環境変数が存在する場合は、SITECORE_SITE_NAMEにリネームします。
-
以下からなる /src/app/lib/client-factory.tsファイルを作成します:
import { GraphQLRequestClientFactoryConfig, GraphQLRequestClient, } from '@sitecore-jss/sitecore-jss-angular'; import { environment as env } from '../../environments/environment';
// The GraphQLRequestClientFactory serves as the central hub for executing GraphQL requests within the application
/** * Creates a new GraphQLRequestClientFactory instance * @returns GraphQLRequestClientFactory instance */ export const createGraphQLClientFactory = () => { let clientConfig: GraphQLRequestClientFactoryConfig;
if (env.graphQLEndpoint && env.sitecoreApiKey) { clientConfig = { endpoint: env.graphQLEndpoint, apiKey: env.sitecoreApiKey, }; } else { throw new Error('Please configure your graphQLEndpoint and sitecoreApiKey.'); }
return GraphQLRequestClient.createClientFactory(clientConfig); };
export const clientFactory = createGraphQLClientFactory();
-
/src/app/lib/layout-service-factory.tsファイルを以下のように修正します:
-
以下のインポートステートメントを追加してください:
import { clientFactory } from './client-factory';
-
もし存在する場合は、以下のGraphQLLayoutServiceコンストラクタオプションを探してください:
endpoint: config.graphQLEndpoint, apiKey: config.sitecoreApiKey,
-
それらのオプションを以下のものに置き換えてください:
clientFactory,
-
-
/src/app/lib/dictionary-service-factory.tsファイルを以下のように修正します:
-
以下のインポートステートメントを追加してください:
import { clientFactory } from './client-factory';
-
もし存在する場合は、以下のGraphQLDictionaryServiceコンストラクタオプションを探してください:
endpoint: config.graphQLEndpoint, apiKey: config.sitecoreApiKey,
-
それらのオプションを以下のものに置き換えてください:
clientFactory,
-
-
以前にAngular 17対応のためにこのアプリをJSS 21.8にアップグレードしている場合は、今後JSS 22.1にアップグレードする必要があります。
Reactアプリの更新
Reactアプリケーションを更新するには:
-
REACT_APP_JSS_APP_NAME環境変数が存在する場合は、REACT_APP_SITECORE_SITE_NAMEに名前を変更します。
-
sitecore-jss/sitecore-jss-reactモジュールからインポートしたImage型を使用するすべてのコンポーネントでは、mediaプロップをfieldにリネームします。
-
以下からなる /src/lib/client-factory.jsファイルを作成します:
import { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss-react'; import config from '../temp/config';
// The GraphQLRequestClientFactory serves as the central hub for executing GraphQL requests within the application
/** * Creates a new GraphQLRequestClientFactory instance * @returns GraphQLRequestClientFactory instance */ export const createGraphQLClientFactory = () => { let clientConfig;
if (config.graphQLEndpoint && config.sitecoreApiKey) { clientConfig = { endpoint: config.graphQLEndpoint, apiKey: config.sitecoreApiKey, }; } else { throw new Error('Please configure your graphQLEndpoint and sitecoreApiKey.'); }
return GraphQLRequestClient.createClientFactory(clientConfig); };
export const clientFactory = createGraphQLClientFactory();
-
/src/lib/layout-service-factory.jsファイルを以下のように修正します:
-
以下のインポートステートメントを追加してください:
import { clientFactory } from './client-factory';
-
もし存在する場合は、以下のGraphQLLayoutServiceコンストラクタオプションを探してください:
endpoint: config.graphQLEndpoint, apiKey: config.sitecoreApiKey,
-
それらのオプションを以下のものに置き換えてください:
clientFactory,
-
-
/src/lib/dictionary-service-factory.jsファイルを以下のように修正します:
-
以下のインポートステートメントを追加してください:
import { clientFactory } from './client-factory';
-
もし存在する場合は、以下のGraphQLDictionaryServiceコンストラクタオプションを探してください:
endpoint: config.graphQLEndpoint, apiKey: config.sitecoreApiKey,
-
それらのオプションを以下のものに置き換えてください:
clientFactory,
-
アプリの更新Vue.js
Vue.js申請を更新するには:
-
VUE_APP_JSS_APP_NAME環境変数が存在する場合は、VUE_APP_SITECORE_SITE_NAMEにリネームします。
-
以下からなる /src/lib/client-factory.jsファイルを作成します:
import { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss-vue'; import config from '../temp/config';
// The GraphQLRequestClientFactory serves as the central hub for executing GraphQL requests within the application
/** * Creates a new GraphQLRequestClientFactory instance * @returns GraphQLRequestClientFactory instance */ export const createGraphQLClientFactory = () => { let clientConfig;
if (config.graphQLEndpoint && config.sitecoreApiKey) { clientConfig = { endpoint: config.graphQLEndpoint, apiKey: config.sitecoreApiKey, }; } else { throw new Error('Please configure your graphQLEndpoint and sitecoreApiKey.'); }
return GraphQLRequestClient.createClientFactory(clientConfig); };
export const clientFactory = createGraphQLClientFactory();
-
/src/lib/layout-service-factory.jsファイルを以下のように修正します:
-
以下のインポートステートメントを追加してください:
import { clientFactory } from './client-factory';
-
もし存在する場合は、以下のGraphQLLayoutServiceコンストラクタオプションを探してください:
endpoint: config.graphQLEndpoint, apiKey: config.sitecoreApiKey,
-
それらのオプションを以下のものに置き換えてください:
clientFactory,
-
-
/src/lib/dictionary-service-factory.jsファイルを以下のように修正します:
-
以下のインポートステートメントを追加してください:
import { clientFactory } from './client-factory';
-
もし存在する場合は、以下のGraphQLDictionaryServiceコンストラクタオプションを探してください:
endpoint: config.graphQLEndpoint, apiKey: config.sitecoreApiKey,
-
それらのオプションを以下のものに置き換えてください:
clientFactory,
-
NodeのヘッドレスSSR Experience Edgeアプリを更新してください
Node headless SSR Experience Edgeアプリのアップデート:
-
以下からなる /src/client-factory.tsファイルを作成します:
import { GraphQLRequestClientFactoryConfig, GraphQLRequestClient, } from '@sitecore-jss/sitecore-jss'; import { config } from './config';
// The GraphQLRequestClientFactory serves as the central hub for executing GraphQL requests within the application
/** * Creates a new GraphQLRequestClientFactory instance * @returns GraphQLRequestClientFactory instance */ export const createGraphQLClientFactory = () => { let clientConfig: GraphQLRequestClientFactoryConfig;
if (config.endpoint && config.apiKey) { clientConfig = { endpoint: config.endpoint, apiKey: config.apiKey, }; } else { throw new Error('Please configure your endpoint and apiKey.'); }
return GraphQLRequestClient.createClientFactory(clientConfig); };
export const clientFactory = createGraphQLClientFactory();
-
/src/index.tsファイルを以下のように修正します:
-
以下のインポートステートメントを追加してください:
import { clientFactory } from './client-factory';
-
もし存在する場合は、以下のGraphQLLayoutServiceコンストラクタオプションを探してください:
endpoint: config.endpoint, apiKey: config.apiKey,
-
それらのオプションを以下のものに置き換えてください:
clientFactory,
-
もし存在する場合は、以下のGraphQLDictionaryServiceコンストラクタオプションを探してください:
endpoint: config.endpoint, apiKey: config.apiKey,
-
それらのオプションを以下のものに置き換えてください:
clientFactory,
-
アプリケーション依存関係の更新
アップグレードしたアプリケーションを正しく動作させるには、依存関係を更新する必要があります。
依存関係を更新するには:
-
既存のアプリケーションのpackage.jsonファイルで、すべての @sitecore-jssパッケージをバージョン ~22.0.0に更新してください。
-
以下のコマンドで依存関係をインストールします:
npm install