Discover our combined Release Notes page and stay updated with the latest features and improvements! Get comprehensive details on all updates, quickly find specific updates and enhancements with our new search and filter options, and easily browse through different versions and sections.
React 19 Migration Guide for Merchant Center Customizations
v24, and the UI Kit packages with a new major version v20.This guide provides detailed information about the migration process and necessary changes for Custom Applications and Custom Views to ensure a successful migration.
Introduced Drawer component
Introduced Custom Views
Each customization type provides unique possibilities for adding custom functionality, as well as offering different user experiences within the Merchant Center.
-
With Custom Views, you can add custom functionality in the context of a specific page within a built-in Merchant Center application.
-
With Custom Applications, you can add new applications with custom functionality to the Merchant Center main menu.
Developing Custom Views is similar to developing Custom Applications because they share many of the same concepts and resources. If you have experience developing Custom Applications, you can use this knowledge to build Custom Views.
Introduced granular permissions for local development of Custom Applications
Administrators team of an Organization.Introduced the new main navigation menu for the Merchant Center
The new main navigation menu brings a fresh look and enhanced functionality to help you navigate your application effortlessly. It provides a smoother and intuitive user experience in the Merchant Center.
ui-kit and app-kit packages to the latest versions.Improved permission management for Custom Applications
This enhancement allows you to make changes to permission, for example, adding new OAuth Scopes, managing permission groups, or removing unused scopes, all without uninstalling the application. With this update, all existing team permissions remain unaffected.
New UI style for the Merchant Center
ui-kit and app-kit dependencies to the latest version. We don't expect you to do any extra work regarding the styles of your components in this regard.Custom Applications v22 and UI Kit v16
v22, as well as the UI Kit packages with a major version v16.This release contains breaking changes.
This release contains some major dependency version updates. We don't expect any migration steps necessary aside some minor test adjustments (see migration steps below).
The following libraries have been updated to new major versions:
@commercetools-frontend/ui-kitand all@commercetools-uikit/*packages have been updated tov16.react-intland@formatjs/clihave been updated tov6.jestand@types/jesthave been updated tov29.jsdomhas been updated tov21.eslint-plugin-jesthas been updated tov27.
v14. Make sure you are using v16 or v18 at least.trackingGtm value, you would need to implement the setup on your own.{/* <!-- more */}
Upgrading peer dependencies
Make sure to upgrade the following dependencies:
react-intland@formatjs/clitov6jestand@types/jesttov29jest-runner-eslinttov2jest-watch-typeaheadtov2
Migrating Jest
@commercetools-frontend/jest-preset-mc-app contains most of the updates and migration changes.We don't expect any specific migration effort besides updating all Jest dependencies to their latest version (including possible Jest plugins being used).
However, there are a couple of possible necessary updates to consider:
- Jest snapshots format changed a bit. You might need to update your snapshots by passing the option
-uto the Jest command. - The ESLint plugin for Jest might yield some new errors due to its breaking changes. See changelog.
For more detailed information about upgrading Jest, please refer to the official guides:
Introducing consistent button sizes in the UI Kit
size prop on the UI Kit button components lets you set the size. However, the size values across different button components were inconsistent. For example, the PrimaryButton supported the small and big sizes while the SecondaryButton only had the big size.15.14.0, the button components accept consistent values for the size prop, as described below.{/* <!-- more */}
PrimaryButton:- Default size:
big. - Available sizes:
medium,big. - Changes: Replaced the
smallsize withmediumfor consistency. Thesmallsize will continue to work until the deprecation notice.
SecondaryButton:- Default size:
big. - Available sizes:
medium,big. - Changes: Added the
mediumsize.
PrimaryIconButton:- Default size:
big. - Available sizes:
small,medium,big. - Changes: No changes.
SecondaryIconButton:- Default size:
big. - Available sizes:
small,medium, andbig. - Changes: Added two new size options—
smallandmedium.
Custom Applications deployment previews
If you're using the legacy workaround of creating multiple Custom Applications with different entry points, we recommend migrating to deployment previews. They provide a better developer experience with less maintenance since you only need to configure one Custom Application.
Support logging in via single sign-on for local development
Custom Applications multiple permissions
v21.21.0.Human-readable page titles
Support for configuring custom HTTP clients
Installing Custom Applications in multiple Organizations
Up until now, this functionality was limited to installing a Custom Application in the same Organization where it was configured. This limitation was mainly posed to reduce the scope of the initial release.
As of today, we are happy to announce that Custom Applications can be installed in other Organizations where the user has administration rights.
Migration deadline postponed for Org-level Custom Application
This gives users a bit more time to finish the migration from Project-level Custom Applications.
Custom Applications v21.8
v21.8.This release includes several new features that we would like to present:
- Official support for developing Custom Applications in TypeScript, including a new starter template. Read more about TypeScript in the Adding TypeScript page.
- New policy option for configuring the
audiencefield when integrating your Custom Application with an external API. - Improved accessibility of different elements using ARIA attributes.
- Simpler and more readable list of time zone data, available from the
@commercetools-frontend/l10npackage. - New React hook
useProjectExtensionImageRegexfor accessing the project images configuration, available from the@commercetools-frontend/application-shell-connectorspackage.
{/* <!-- more */}
Deprecations
mc-scripts CLI has deprecated some entry points.createPostcssConfig from the main entry point @commercetools-frontend/mc-scripts is now deprecated. Use the entry point @commercetools-frontend/mc-scripts/postcss instead.const {
createPostcssConfig,
-} = require('@commercetools-frontend/mc-scripts');
+} = require('@commercetools-frontend/mc-scripts/postcss');
createWebpackConfigForDevelopment and createWebpackConfigForProduction from the main entry point @commercetools-frontend/mc-scripts is now deprecated. Use the entry point @commercetools-frontend/mc-scripts/webpack instead.const {
createWebpackConfigForDevelopment,
createWebpackConfigForProduction,
-} = require('@commercetools-frontend/mc-scripts');
+} = require('@commercetools-frontend/mc-scripts/webpack');
Custom Applications become generally available
After collecting feedback during the beta phase, and with the recent milestone of migrating Custom Applications to Org-level, we now have a solid foundation on the functionalities and developer tooling for Custom Applications.
Custom Applications v21.6
v21.6.This release includes several new features that we would like to present:
- A new built-in Stacking Layer System to automatically and consistently calculate
z-indexvalues of stacked modal containers. - New layout UI components
<InfoDetailPage>,<FormDetailPage>and<CustomFormDetailPage>. - The CLI commands
config:syncnow lists changes when updating an existing Custom Application configuration. - The Jest preset
@commercetools-backend/jest-preset-mc-appcontains more Intl polyfills.
{/* <!-- more */}
Background
portals-container.zIndex or level props, to imperatively determine how the component will be visible.
This was required as the modal containers are positioned absolute and finding the correct z-index value is important.z-index results in the modal to not be visible and thus leading to UI bugs.z-index values for every modal container rendered on the page.Stacking Layer System
z-index values for every modal container.zIndex and level props to the modal pages or dialog components. The following props have been deprecated: level and baseZIndex (modal pages).remove-deprecated-modal-level-props:$ npx @commercetools-frontend/codemod remove-deprecated-modal-level-props 'src/**/*.js'
zIndex prop is still supported and, if defined, it will overwrite the z-index value using !important. Therefore we recommend to only define it if absolutely necessary, otherwise it's safe to remove it.Custom Applications v21.3
v21.3.This release includes several new features that we would like to present:
- New CLI commands
loginandconfig:syncto help maintaining Custom Applications. - New layout UI components
<TabularMainPage>and<TabularDetailPage>. In addition to that, a new<TabHeader>component is exported from the@commercetools-frontend/application-componentspackage to be used in the tabular UI components<TabularModalPage>,<TabularMainPage>and<TabularDetailPage>. - New ESLint config
@commercetools-backend/eslint-config-nodefor Node.js projects with built-in TypeScript support. - The notification components now support the aria role
alertdialogand thearia-describedbyattributes. This helps in particular to write more specific and relevant selector in tests.
Custom Applications v21
v21.This release contains breaking changes.
This version marks the release of new Custom Application features.
Furthermore, the Custom Application documentation has been restructured and updated to match the new status quo of Custom Applications. The Project-level legacy documentation remains available during the migration period in a separate location.
Follow the steps below to migrate your Application Kit packages to the new version.
{/* <!-- more */}
New documentation
The Custom Applications documentation has been restructured and improved to provide a better developer experience. During the migration period the Project-level legacy documentation remains available for maintenance and reference purposes.
Supported Node.js versions
v12 has been dropped. Recommended versions are v14 or v16.Upgrading ESLint to v8
v8 as the minimal required version. Make sure to upgrade the eslint package to v8 and any other ESLint-related package to their latest version.The upgrade might include some rule changes and therefore some lint errors that need to be fixed.
Changes to peer dependencies
The following packages have updated their peer dependencies requirements:
@commercetools-frontend/application-shell: requires@testing-library/reactversion12.xand@testing-library/react-hooksversion7.x.@commercetools-frontend/cypress: requirescypressversion8.x || 9.x.@commercetools-frontend/jest-stylelint-runner: requiresstylelintversion14.x.
Changes to Custom Application config
The Custom Application config file has some new required fields.
env.developmentoAuthScopes*.defaultLabel
In addition to that, the menu link structure also changed a bit.
// Before
{
"menuLinks": {
"icon": "HeartIcon",
"defaultLabel": "Starter",
"labelAllLocales": [],
"permissions": [],
"submenuLinks": [
{
"uriPath": "channels",
"defaultLabel": "Channels",
"labelAllLocales": [],
"permissions": []
}
]
}
}
// After
{
"icon": "${path:@commercetools-frontend/assets/application-icons/rocket.svg}",
"mainMenuLink": {
"defaultLabel": "Starter",
"labelAllLocales": [],
"permissions": [],
},
"submenuLinks": [
{
"uriPath": "channels",
"defaultLabel": "Channels",
"labelAllLocales": [],
"permissions": []
}
]
}
defaultLabel, which is used in case there is no localized label for the user's locale. If you don't need localized labels, you can leave the labelAllLocales field empty and only use the defaultLabel.Referencing constants
entryPointUriPath and the user permissions in a constants.js file. The user permissions can be computed using the entryPointUriPathToPermissionKeys function, to avoid defining them manually.import { entryPointUriPathToPermissionKeys } from '@commercetools-frontend/application-shell/ssr';
export const entryPointUriPath = 'channels';
export const PERMISSIONS = entryPointUriPathToPermissionKeys(entryPointUriPath);
PERMISSIONS variable contains a View and Manage properties, with the values being the computed values based on the entryPointUriPath..mjs file extension):import { entryPointUriPath, PERMISSIONS } from './src/constants';
const config = {
entryPointUriPath,
mainMenuLink: {
permissions: [PERMISSIONS.View],
},
// ...
};
export default config;
Migrating from menu.json
menu.json file has been removed. The menu links must be defined now in the Custom Application config file.DEV_ONLY__loadNavbarMenuConfig prop of the <ApplicationShell> has been removed as well.New login workflow
Starting the Custom Application locally now redirects you to the login page of the Merchant Center production environment (as defined in the Custom Application config). Upon successful login, you are redirected back to your local development server with a valid session.
ENABLE_OIDC_FOR_DEVELOPMENT=true, this is now the default behavior and you can remove the environment variable.Recommended setup for EntryPoint
<EntryPoint> component we recommend to render the application content as children of <ApplicationShell> instead of the render prop.<ApplicationShell> to pre-configure the application entry point routes. In addition to that, the entry point route is protected by the basic View permission check. This means that a user without permissions of your Custom Application won't be able to access the Custom Application route.import { ApplicationShell } from '@commercetools-frontend/application-shell';
const loadMessages = async (locale) => {
// ...
};
const AsyncApplicationRoutes = React.lazy(() => import('../../routes'));
const EntryPoint = () => (
<ApplicationShell environment={window.app} applicationMessages={loadMessages}>
<AsyncApplicationRoutes />
</ApplicationShell>
);
export default EntryPoint;
Changes to the CLI
mc-scripts CLI has some breaking changes about the commands:- In
mc-scripts, thebuildcommand additionally compiles theindex.htmlby default.- Running the
compile-htmlcommand by default should not be necessary anymore. However, you can pass--build-onlyto thebuildcommand to opt-out of the compilation step, in case you want to run it separately, for example to use the--transformer.
- Running the
- Running the
compile-htmlcommand by default does not print tostdoutthe JSON string with the security headers. You can opt into the old behavior by passing the--print-security-headersoption. - The
--inline-cspofcompile-htmlhas been dropped, as it's now the built-in behavior. - The
distfolder created by thebuildcommand has been removed. Instead, thebuildcommand writes the production bundles directly into thepublicfolder.
Better deployments support
With the new improvements in the developer tools, it's now even simpler to deploy a Custom Application to all the major hosting services. In fact, you can now take advantage of the GitHub integration with some of those hosting providers, without any extra effort around configuration.
--transformer option of the compile-html command to configure the configuration file of the hosting provider.Now most of the things are built-in and defined as defaults, removing the need to dynamically create a configuration file. As a result, configurations for the hosting provider can be defined statically, thus allowing to fully use the GitHub integration features.
Changes to Test Utils
@commercetools-frontend/application-shell/test-utils has the following breaking changes:-
The
disableApolloMocksoption has been removed. By default, the Apollo mocks are deactivated. This is to encourage mocking via Mock Service Worker. To opt into the usage of Apollo mocks, you only need to pass themocksproperty with a non-empty array. See Testing for more information. -
The
disableAutomaticEntryPointRoutesoption now defaults tofalse. This means that when rendering the<ApplicationShell>, you should not use therenderfunction but pass the application component usingchildren.const EntryPoint = () => ( <ApplicationShell environment={window.app} applicationMessages={loadMessages} > <AsyncApplicationRoutes /> </ApplicationShell> ); -
The application
Viewpermission is automatically applied to theprojectobject, based on theenvironment.entryPointUriPathvalue. You can always override the permission values by explicitly assigningproject.allAppliedPermissions. -
The deprecated
project.allAppliedMenuVisibilitiesoption has been removed. -
The deprecated
permissionsoption has been removed. Useproject.allAppliedPermissionsinstead.// Before { permissions: { canManageProducts: true; } } // After { project: { allAppliedPermissions: [{ name: 'canManageProducts', value: true }]; } }You can also use the helper functionmapResourceAccessToAppliedPermissions(recommended)import { mapResourceAccessToAppliedPermissions } from '@commercetools-frontend/application-shell/test-utils'; { project: { allAppliedPermissions: mapResourceAccessToAppliedPermissions([ PERMISSIONS.View ]) }, }or thedenormalizePermissionsfunction.import { denormalizePermissions } from '@commercetools-frontend/application-shell/test-utils'; { project: { allAppliedPermissions: denormalizePermissions({ canManageProducts: true, }); } }
mapResourceAccessToAppliedPermissions or denormalizePermissions.@commercetools-frontend/cypress package to be able to use the cy.loginByOidc command. See End-to-End tests for more information.Rewrite of Starter template
The Custom Application Starter template has been rewritten from scratch, to provide a better experience to new developers working on Custom Applications.
Below an overview of the most important changes:
{/* <!-- more */}
- The template now has more built-in dev tools, like ESLint and Prettier.
- The template README has been cleaned up a bit.
- The template uses the new React JSX transform.
- The template uses the new menu links in application config.
- The template has a nicer landing/welcome page with useful links to get started.
- The template has a
channelspage, that fetches channels and renders them in a table. This is a good showcase of some of our best practices, for example to use hooks, to use GraphQL, to use notifications, to render data in a table (with pagination), etc. - The template has React-Testing-Library tests, including mocking GraphQL and using test data.
@commercetools-frontend/create-mc-app package now automatically derives the entryPointUriPath from the folder name when installing the template. The value is then applied to the application config and other places in the source code.Custom Applications v19
v19.This release contains breaking changes.
This version does not contain explicit changes in our packages but mainly updates to major versions of some of the depended upon libraries. For instance:
@commercetools-frontend/ui-kitand all@commercetools-uikit/*packages have been updated tov12.reactandreact-domhave been updated tov17.graphqlhas been updated tov15.webpackhas been updated tov5
CHANGELOG.md.{/* <!-- more */}
Migrating UI Kit packages
Constraints
<Constraints.Horizontal /> component, the deprecated constraint prop has been removed. Now only the max prop can be used instead.- <Constraints.Horizontal constraint="m" />
+ <Constraints.Horizontal max={7} />
constraint to max is as following:constraint | max |
| ---------------- | ---------------- |
| xs (50px) | 1 (42px) |
| s (132px) | 3 (142px) |
| m (355px) | 7 (342px) |
| l (496px) | 10 (484px) |
| xl (768px) | 16 (784px) |Text
{/* vale off */}
<Text.Headline> and <Text.Subheadline> components, the deprecated elementType prop has been removed. Now only the as prop is used instead.{/* vale on */}
- <Text.Headline elementType="h2" intlMessage={message} />
+ <Text.Headline as="h2" intlMessage={message} />
{/* vale off */}
<Text.Body> and <Text.Detail> components, the deprecated isInline prop has been removed. Now only the as prop can be used instead.{/* vale on */}
- <Text.Body isInline={true} intlMessage={message} />
+ <Text.Body as="span" intlMessage={message} />
Link
<Link> component, the deprecated hasUnderline prop has been removed. Links now always have an underline style applied.isExternal is used and the to prop is not a string but a location object, an error is thrown.Tag
<Tag> component, the deprecated linkTo prop has been removed. Now only the to prop can be used instead.SecondaryButton
<SecondaryButton> component, the deprecated linkTo prop has been removed. Now only the to prop can be used instead.Custom Applications v18
v18.This release contains breaking changes.
@commercetools-frontend/eslint-config-mc-app package, where eslint is now the only required peer dependency.
Additionally, the ESLint config uses the ESLint React App config as a base instead of Airbnb.Most of the rules have stayed the same, however you may need to adjust or fix some depending on your usage.
mc.commercetools.com and mc.commercetools.co from the default Content Security Policy configuration.
This is aligned with the long-running effort of moving the Merchant Center to use the new URLs.connect-src config of the custom-application-config.json.Follow the steps below to migrate your ESLint config to the new version.
{/* <!-- more */}
Migrating @commercetools-frontend/eslint-config-mc-app
Simply remove all ESLint related dependencies that where previously required as peer dependencies.
{
- "babel-eslint": "10.1.0",
"eslint": "7.18.0"
- "eslint-config-airbnb-base": "14.2.1",
- "eslint-config-prettier": "7.2.0",
- "eslint-plugin-babel": "5.3.1",
- "eslint-plugin-import": "2.22.1",
- "eslint-plugin-jest": "24.1.3",
- "eslint-plugin-jest-dom": "3.6.5",
- "eslint-plugin-jsx-a11y": "6.4.1",
- "eslint-plugin-prefer-object-spread": "1.2.1",
- "eslint-plugin-prettier": "3.3.1",
- "eslint-plugin-react": "7.22.0"
}
As a reminder, the ESLint config can be used as following:
module.exports = {
extends: ['@commercetools-frontend/eslint-config-mc-app'],
};
GitHub Discussions available for application-kit and ui-kit repositories.
We are really excited about it and we hope you find it useful too.
Custom Applications v17
v17. One of the most important changes in this release is about migrating to the new Apollo Client v3.This release contains breaking changes.
Follow the steps below to migrate your Custom Application to the new versions.
{/* <!-- more */}
Migrating to Apollo Client v3
v3 requires some important migration steps.Migrating Apollo imports
@apollo/client instead of multiple ones.apollo-client and react-apollo are now replaced with the new peer dependency of @apollo/client.About the new Apollo Cache
v3, the Apollo in-memory cache got some improvements as well, resulting in some breaking changes. Please make sure to read this document to understand the changes.id field as identifier, or if Apollo cannot automatically merge two objects that have different fields shape, and so on.If that is the case, you need to configure the Apollo cache according to your needs, as only you know what the best caching strategy for your Custom Application is.
<ApplicationShell> component now accepts an apolloClient prop, that allows you to configure your own instance of the Apollo client with the custom cache configuration.@commercetools-frontend/application-shell package exposes a createApolloClient function that allows you to create a new Apollo client pre-configured with some important defaults (for example Apollo links, some basic cache policies, etc.).import {
createApolloClient,
ApplicationShell,
} from '@commercetools-frontend/application-shell';
const apolloClient = createApolloClient({
cache: {
// Your custom configuration, according to the Apollo cache documentation.
// https://www.apollographql.com/docs/react/caching/cache-configuration/
},
});
const Application = () => {
return (
<ApplicationShell
apolloClient={apolloClient}
// ...other props
/>
);
};
Changes about Apollo query variables and context
variables object, which the built-in Merchant Center Apollo HTTP Link would parse and assign it to the request as HTTP headers. We call these options request context.context option in Apollo Client, we can pass the request metadata options to the context object instead of the variables object.const { loading, data, error } = useQuery(MyQuery, {
- variables: {
+ context: {
target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM,
},
});
targetprojectKey
variables object still works for backwards compatibility but it is recommended to use the context object instead.Enforcing a valid context object
context object.
To improve the TypeScript support and auto-completion for the request context options, the @commercetools-frontend/application-shell package now exports new React hooks. Note that autocompletion is possible, even if you are not using TypeScript.useMcQueryuseMcLazyQueryuseMcMutation
context object is properly typed to conform with the Merchant Center request context instead of any.-import { useQuery } from '@apollo/client/react';
+import { useMcQuery } from '@commercetools-frontend/application-shell';
-const { loading, data, error } = useQuery(MyQuery, {
+const { loading, data, error } = useMcQuery(MyQuery, {
context: {
target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM,
},
});
Changes about the mc-scripts CLI
Removing deprecated options from compile-html
--env, --csp, --headers, have been removed.--use-local-assets has been removed as well. As such the default behavior of mc-scripts compile-html changed to compile the assets locally.mc-scripts compile-html command, the index.html is compiled for production usage and it lives in the public folder, together with the other static assets. This is all you need to deploy your application.
You can decide to deploy the Custom Application statically to one of the popular cloud providers, or serve the files on your own using a static server.For example, to run locally the Custom Application using the production bundles:
NODE_ENV=production MC_APP_ENV=development dotenv -- \
mc-scripts compile-html \
--transformer @commercetools-frontend/mc-dev-authentication/transformer-local.js
mc-scripts serve
Removing the mc-http-server package
@commercetools-frontend/mc-http-server package has been deprecated and will not receive any updates.compile-html command there is no need to have a pre-configured HTTP server anymore. If you are using this package, we recommend to use any other HTTP server package to serve your static files.New command serve
mc-scripts serve that can be used to start your Custom Application locally in production mode after it has been compiled.public folder./login and /logout. Do not use this command to serve your Custom Application in production.Before:
{
"start:prod:local": "NODE_ENV=production MC_APP_ENV=development dotenv -- mc-http-server --use-local-assets"
}
After:
{
"compile-html:local": "NODE_ENV=production MC_APP_ENV=development dotenv -- mc-scripts compile-html --transformer @commercetools-frontend/mc-dev-authentication/transformer-local.js",
"start:prod:local": "yarn compile-html:local && mc-scripts serve"
}
Removing the extract-intl command
mc-scripts extract-intl command has been removed in favor of the official @formatjs/cli package.formatjs extract command.Before:
{
"i18n:build": "mc-scripts extract-intl --output-path=$(pwd)/src/i18n/data 'src/**/!(*.spec).js' --build-translations"
}
After:
{
"extract-intl": "formatjs extract --format=$(pwd)/intl-formatter.js --out-file=$(pwd)/src/i18n/data/core.json 'src/**/!(*.spec).js'"
}
intl-formatter.js should be defined as something like this, depending on your translation tool's needs:// https://formatjs.github.io/docs/tooling/cli#extraction
exports.format = function format(extractedMessages) {
return (
Object.keys(extractedMessages)
// transform strings to lowercase to imitate phraseapp sorting
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
.reduce(
(allMessages, messageId) => ({
...allMessages,
// Return a simple key/value JSON object.
[messageId]: extractedMessages[messageId].defaultMessage,
}),
{}
)
);
};
Changes about the experimentalRenderAppWithRedux from test utils
experimentalRenderAppWithRedux from the test-utils has been removed.disableApolloMocks option to the renderApp and renderAppWithRedux methods. When this option is set to true, the real ApolloProvider is rendered instead of Apollo's MockProvider.apolloClient instance together with the disableApolloMocks option. This is only needed when your Custom Application uses a custom apolloClient, for example for configuring the cache policies.Removing the deprecated options from application-shell
@commercetools-frontend/application-shell package no longer exports the deprecated AsyncChunkLoader and handleApolloErrors.trackingEventWhitelist of the <ApplicationShell> component has been removed as well.Introducing a new and simpler application config
env.json and headers.json files.env.json and headers.json files will still keep working but they will be removed in the next major release.Furthermore, the new configuration process tries to infer as much information as possible to reduce the amount of required fields.
{/* <!-- more */}
Migrating to the new configuration file format
The new configuration file is a JSON file with one of the following names:
.custom-application-configrc.custom-application-config.jsoncustom-application-config.json
mc-scripts commands.env.json and headers.json files:{
"applicationName": "Channels app",
"frontendHost": "localhost:3001",
"mcApiUrl": "https://mc-api.europe-west1.gcp.commercetools.com",
"location": "gcp-eu",
"env": "development",
"cdnUrl": "http://localhost:3001",
"servedByProxy": false
}
{
"csp": {
"script-src": [],
"connect-src": ["mc-api.europe-west1.gcp.commercetools.com"],
"style-src": []
}
}
env.prod.json and headers.prod.json:{
"applicationName": "Channels app",
"frontendHost": "channels.app",
"mcApiUrl": "https://mc-api.europe-west1.gcp.commercetools.com",
"location": "gcp-eu",
"env": "production",
"cdnUrl": "https://cdn.channels.app",
"servedByProxy": true
}
{
"csp": {
"script-src": ["channels.app", "cdn.channels.app"],
"connect-src": [
"mc-api.europe-west1.gcp.commercetools.com",
"channels.app",
"cdn.channels.app"
],
"style-src": ["channels.app", "cdn.channels.app"]
}
}
custom-application-config.json (or one of the other file names) with the following content:{
"name": "Channels app",
"entryPointUriPath": "channels",
"cloudIdentifier": "gcp-eu",
"env": {
"production": {
"url": "https://channels.app",
"cdnUrl": "https://cdn.channels.app"
}
}
}
That's it! All other values are inferred from the config, like the Content-Security-Policy (CSP) headers, etc.
${env:VALUE} continues to work.Migrating mc-scripts commands
mc-scripts commands in the package.json{
"scripts": {
- "start:prod:local": "NODE_ENV=production dotenv -- mc-http-server --config=$(pwd)/env.json --headers=$(pwd)/headers.json --use-local-assets"
+ "start:prod:local": "NODE_ENV=production MC_APP_ENV=development dotenv -- mc-http-server --use-local-assets"
}
}
docker run \
-v $(pwd):/etc/app \
-p 8080:8080 \
- eu.gcr.io/ct-images/mc-http-server \
+ eu.gcr.io/ct-images/mc-http-server
- --config /etc/app/env.json \
- --headers /etc/app/headers.json
{
"scripts": {
- "compile-html": "mc-scripts compile-html --headers=$(pwd)/headers.prod.json --config=$(pwd)/env.prod.json --use-local-assets --transformer $(pwd)/transformer-vercel.js"
+ "compile-html": "mc-scripts compile-html --use-local-assets --transformer $(pwd)/transformer-vercel.js"
}
}
JSON Schema support for VSCode
In the VSCode settings (either user settings or workspace settings), reference the schema JSON as described below:
"json.schemas": [
{
"fileMatch": [
"/.custom-application-configrc",
"/.custom-application-config.json",
"/custom-application-config.json"
],
"url": "https://docs.commercetools.com/merchant-center-customizations/schema.json"
}
]
With that, the editor can offer autocompletion and validation of the JSON properties.
Migrate Custom Applications to the new host naming scheme
*.sphere.io (Google Cloud, Belgium), *.commercetools.com (Google Cloud, Belgium), and *.commercetools.co (Google Cloud, Iowa) continue to be operational, we strongly recommend to migrate to the new hostname structure.If you are using the [new application config file][/development/application-config], you can ignore the migration steps as the hostnames are automatically configured.
Here are the steps to take.
{/* <!-- more */}
1. Update dependencies
>= 16.2.1, in particular the @commercetools-frontend/application-shell package. This is important to ensure that certain functionalities related to the hostname migration are available.To update all the application kit packages to a specific version, you can use the following script:
npx bulk-update-versions \
--match '^@commercetools-frontend/(?!ui-kit)(.*)' \
--force-latest
yarn install
bulk-update-versions script with the --force-latest option bumps all packages matching the specified pattern to their latest version.v16, follow the instructions in the changelogs.2. Update the env.json
mcApiUrl in the env.json to use the new hostname.For example:
{
"applicationName": "merchant-center-application-template-starter",
"frontendHost": "localhost:3001",
"mcApiUrl": "https://mc-api.europe-west1.gcp.commercetools.com",
"location": "eu",
"env": "development",
"cdnUrl": "http://localhost:3001",
"servedByProxy": false
}
<ApplicationShell> takes care of inferring the correct Merchant Center Gateway API hostname based on the Merchant Center hostname that the user is logged into.
This results in the Custom Application to work in both new and legacy hostnames, even though the mcApiUrl is configured to a specific value.16.2.1 onwards.3. Update the headers.json
Update the Content Security Policy to allow both new and legacy hostnames.
For example:
{
"csp": {
"script-src": ["my-app.vercel.app"],
"connect-src": [
"my-app.vercel.app",
"mc-api.europe-west1.gcp.commercetools.com",
"mc-api.commercetools.com"
],
"style-src": ["my-app.vercel.app"]
}
}
4. Re-deploy the Custom Application
That's it. Re-deploy the Custom Application with the updated configuration. Users can now access the Custom Application using both new and legacy hostnames (for backwards compatibility).