From b57c724bede8a37a1005d8b419ef30a87599ae90 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sat, 16 Mar 2019 15:41:14 -0400 Subject: [PATCH] same but for SSR --- src/compile/render-ssr/index.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/compile/render-ssr/index.ts b/src/compile/render-ssr/index.ts index 64846f36cb..9e10733e37 100644 --- a/src/compile/render-ssr/index.ts +++ b/src/compile/render-ssr/index.ts @@ -27,13 +27,14 @@ export default function ssr( const reactive_stores = component.vars.filter(variable => variable.name[0] === '$' && variable.name[1] !== '$'); const reactive_store_values = reactive_stores .map(({ name }) => { - const store = component.var_lookup.get(name.slice(1)); - if (store.hoistable) return; + const store_name = name.slice(1); + const store = component.var_lookup.get(store_name); + if (store && store.hoistable) return; - const assignment = `${name} = @get_store_value(${store.name});`; + const assignment = `${name} = @get_store_value(${store_name});`; return component.compileOptions.dev - ? `@validate_store(${store.name}, '${store.name}'); ${assignment}` + ? `@validate_store(${store_name}, '${store_name}'); ${assignment}` : assignment; }); @@ -95,10 +96,11 @@ export default function ssr( const blocks = [ reactive_stores.length > 0 && `let ${reactive_stores .map(({ name }) => { - const store = component.var_lookup.get(name.slice(1)); - if (store.hoistable) { + const store_name = name.slice(1); + const store = component.var_lookup.get(store_name); + if (store && store.hoistable) { const get_store_value = component.helper('get_store_value'); - return `${name} = ${get_store_value}(${store.name})`; + return `${name} = ${get_store_value}(${store_name})`; } return name; })