From f7f03dc4b523db9a9f9d53231bf983b6301ec0e5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 5 Dec 2018 22:18:21 -0500 Subject: [PATCH] tweak output --- src/compile/render-ssr/index.ts | 15 ++++++++------- .../action-custom-event-handler/expected.js | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/compile/render-ssr/index.ts b/src/compile/render-ssr/index.ts index 8570a5db18..83f8ee9629 100644 --- a/src/compile/render-ssr/index.ts +++ b/src/compile/render-ssr/index.ts @@ -58,6 +58,13 @@ export default function ssr( ` : `return \`${renderer.code}\`;`; + const blocks = [ + setup, + parent_bindings.join('\n'), + css.code && `$$result.css.add(#css);`, + main + ].filter(Boolean); + return (deindent` ${css.code && deindent` const #css = { @@ -70,13 +77,7 @@ export default function ssr( ${component.fully_hoisted.length > 0 && component.fully_hoisted.join('\n\n')} const ${name} = @create_ssr_component(($$result, $$props, $$bindings, $$slots) => { - ${setup} - - ${parent_bindings} - - ${css.code && `$$result.css.add(#css);`} - - ${main} + ${blocks.join('\n\n')} }); `).trim(); } diff --git a/test/js/samples/action-custom-event-handler/expected.js b/test/js/samples/action-custom-event-handler/expected.js index 93a4ce1d76..4f32ceeb3b 100644 --- a/test/js/samples/action-custom-event-handler/expected.js +++ b/test/js/samples/action-custom-event-handler/expected.js @@ -48,6 +48,8 @@ function define($$self, $$props) { /* HOISTED */ + /* HOISTED */ + function foo_function() { return handleFoo(bar); }