From 5628e62194b5b230047476c9eba6ab6329d68fc0 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 15 Aug 2023 13:49:43 -0500 Subject: [PATCH] feat: do not include redundant metadata --- packages/astro/src/runtime/server/hydration.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/astro/src/runtime/server/hydration.ts b/packages/astro/src/runtime/server/hydration.ts index 2db8550be..fe751d660 100644 --- a/packages/astro/src/runtime/server/hydration.ts +++ b/packages/astro/src/runtime/server/hydration.ts @@ -155,7 +155,7 @@ export async function generateHydrateScript( // Add renderer url if (renderer.clientEntrypoint) { - scriptProps['componentExport'] = componentExport.value; + if (componentExport.value !== 'default') scriptProps['componentExport'] = componentExport.value; scriptProps['rendererUrl'] = await result.resolve(decodeURI(renderer.clientEntrypoint)); } @@ -165,11 +165,16 @@ export async function generateHydrateScript( if (beforeHydrationUrl.length) { scriptProps['beforeHydrationUrl'] = beforeHydrationUrl; } - scriptProps['opts'] = { - name: metadata.displayName, - value: metadata.hydrateArgs || '', + scriptProps['opts'] = {}; + if (metadata.displayName) { + scriptProps.opts.name = metadata.displayName; + } + if (metadata.hydrateArgs !== true) { + scriptProps.opts.value = metadata.hydrateArgs; + } + if (typeof props === 'object' && Object.keys(props).length > 0) { + scriptProps['props'] = props; } - scriptProps['props'] = props; transitionDirectivesToCopyOnIsland.forEach((name) => { if (props[name]) {