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); }