diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index c0077bf792..6b39247141 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -474,12 +474,22 @@ function cleanManifestList(manifests) { return cleanedList; } -export async function applyPers(manifests) { - if (!manifests?.length) return; - const cleanedManifests = cleanManifestList(manifests); +const decoratePreviewCheck = async (config, experiments) => { + if (config.mep?.preview) { + const { default: decoratePreviewMode } = await import('./preview.js'); + decoratePreviewMode(experiments); + } +}; +export async function applyPers(manifests) { const config = getConfig(); + if (!manifests?.length) { + decoratePreviewCheck(config, []); + return; + } + const cleanedManifests = cleanManifestList(manifests); + let results = []; for (const manifest of cleanedManifests) { results.push(await runPersonalization(manifest, config)); @@ -495,8 +505,5 @@ export async function applyPers(manifests) { expFragments: consolidateObjects(results, 'fragments'), }); - if (config.mep?.preview) { - const { default: decoratePreviewMode } = await import('./preview.js'); - decoratePreviewMode(experiments); - } + decoratePreviewCheck(config, experiments); }