From 4fbea393d31fe7ab2064d48f0a8b2f1e0d61810d Mon Sep 17 00:00:00 2001 From: Victor Fernandez de Alba Date: Sun, 8 Dec 2024 23:45:33 +0100 Subject: [PATCH 1/2] Fixed circular import error in dev with HMR in `App` component when imported in the main default config. --- packages/volto/src/config/Components.jsx | 15 +++++++++------ packages/volto/src/config/index.js | 5 +++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/volto/src/config/Components.jsx b/packages/volto/src/config/Components.jsx index bd6fea6f85..420a175b43 100644 --- a/packages/volto/src/config/Components.jsx +++ b/packages/volto/src/config/Components.jsx @@ -2,9 +2,12 @@ import App from '@plone/volto/components/theme/App/App'; import PreviewImage from '@plone/volto/components/theme/PreviewImage/PreviewImage'; import Image from '@plone/volto/components/theme/Image/Image'; -// Register components. -export const components = { - PreviewImage: { component: PreviewImage }, - App: { component: App }, - Image: { component: Image }, -}; +export function installDefaultComponents(config) { + config.components = { + PreviewImage: { component: PreviewImage }, + App: { component: App }, + Image: { component: Image }, + }; + + return config; +} diff --git a/packages/volto/src/config/index.js b/packages/volto/src/config/index.js index 348b21319d..c689a84b73 100644 --- a/packages/volto/src/config/index.js +++ b/packages/volto/src/config/index.js @@ -16,7 +16,6 @@ import { initialBlocks, initialBlocksFocus, } from './Blocks'; -import { components } from './Components'; import { loadables } from './Loadables'; import { workflowMapping } from './Workflows'; import slots from './slots'; @@ -33,6 +32,7 @@ import { import applyAddonConfiguration, { addonsInfo } from 'load-volto-addons'; import ConfigRegistry from '@plone/volto/registry'; +import { installDefaultComponents } from './Components'; import { getSiteAsyncPropExtender } from '@plone/volto/helpers/Site'; import { registerValidators } from './validation'; @@ -216,7 +216,7 @@ let config = { }, addonRoutes: [], addonReducers: {}, - components, + components: {}, slots: {}, utilities: {}, }; @@ -261,5 +261,6 @@ Object.entries(slots).forEach(([slotName, components]) => { }); registerValidators(ConfigRegistry); +installDefaultComponents(ConfigRegistry); applyAddonConfiguration(ConfigRegistry); From f429caaa2045f06bcdfa0538dcb46707186327fb Mon Sep 17 00:00:00 2001 From: Victor Fernandez de Alba Date: Sun, 8 Dec 2024 23:53:57 +0100 Subject: [PATCH 2/2] Changelog --- packages/volto/news/6524.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/volto/news/6524.bugfix diff --git a/packages/volto/news/6524.bugfix b/packages/volto/news/6524.bugfix new file mode 100644 index 0000000000..36aaa29264 --- /dev/null +++ b/packages/volto/news/6524.bugfix @@ -0,0 +1 @@ +Fixed circular import error in dev with HMR in `App` component when imported in the main default config. @sneridagh