From f165b78ad2ba6cc25069849715cc821adb035a81 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Tue, 22 Feb 2022 03:53:21 -0600 Subject: [PATCH] Make Non-HTML Pages work for static build (#2638) * Make Non-HTML Pages work for static build * Check hasOwnProperty instead of length * Fix typo "> 0" --- packages/astro/src/core/render/dev/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/core/render/dev/index.ts b/packages/astro/src/core/render/dev/index.ts index 1fe4a52470..9eaf6323f3 100644 --- a/packages/astro/src/core/render/dev/index.ts +++ b/packages/astro/src/core/render/dev/index.ts @@ -50,10 +50,10 @@ export async function render(renderers: Renderer[], mod: ComponentInstance, ssrO const { astroConfig, filePath, logging, mode, origin, pathname, route, routeCache, viteServer } = ssrOpts; // Add hoisted script tags - const scripts = createModuleScriptElementWithSrcSet(astroConfig.buildOptions.experimentalStaticBuild ? Array.from(mod.$$metadata.hoistedScriptPaths()) : []); + const scripts = createModuleScriptElementWithSrcSet(astroConfig.buildOptions.experimentalStaticBuild && mod.hasOwnProperty('$$metadata') ? Array.from(mod.$$metadata.hoistedScriptPaths()) : []); // Inject HMR scripts - if (mode === 'development' && astroConfig.buildOptions.experimentalStaticBuild) { + if (mod.hasOwnProperty('$$metadata') && mode === 'development' && astroConfig.buildOptions.experimentalStaticBuild) { scripts.add({ props: { type: 'module', src: '/@vite/client' }, children: '',