diff --git a/packages/hydration/vue.ts b/packages/hydration/vue.ts index 1948c7dc..64a1591f 100644 --- a/packages/hydration/vue.ts +++ b/packages/hydration/vue.ts @@ -1,10 +1,8 @@ -import { h, createApp as createClientApp, createStaticVNode, createSSRApp } from 'vue' +import { h, createStaticVNode, createSSRApp as createVueApp } from 'vue' import type { DefineComponent as Component, Component as App } from 'vue' import type { Props, Slots } from './types' import { onDispose } from './hydration' -const createVueApp = import.meta.env.SSR ? createSSRApp : createClientApp - // Internal: Creates a Vue app and mounts it on the specified island root. export default function createVueIsland (component: Component, id: string, el: Element, props: Props, slots: Slots | undefined) { const slotFns = slots && Object.fromEntries(Object.entries(slots).map(([slotName, content]) => { @@ -17,7 +15,7 @@ export default function createVueIsland (component: Component, id: string, el: E appDefinition.name = `Island: ${nameFromFile(component.__file)}` const app = createVueApp(appDefinition) - app.mount(el!, Boolean(slots)) + app.mount(el!, true) if (import.meta.env.DISPOSE_ISLANDS) onDispose(id, app.unmount) diff --git a/packages/iles/src/client/app/composables/vueRenderer.ts b/packages/iles/src/client/app/composables/vueRenderer.ts index 7550ff20..d454b983 100644 --- a/packages/iles/src/client/app/composables/vueRenderer.ts +++ b/packages/iles/src/client/app/composables/vueRenderer.ts @@ -1,7 +1,5 @@ import type { AppContext, Component, VNode, AsyncComponentLoader } from 'vue' -import { h, getCurrentInstance, createApp, createSSRApp, ssrContextKey, withCtx } from 'vue' - -const newApp = import.meta.env.SSR ? createApp : createSSRApp +import { h, getCurrentInstance, createSSRApp as newApp, ssrContextKey, withCtx } from 'vue' export type Nodes = undefined | VNode | VNode[] export type VueRenderable = AsyncComponentLoader | Component | Nodes | ((props?: any) => Nodes | Promise) diff --git a/packages/iles/src/client/app/index.ts b/packages/iles/src/client/app/index.ts index 9b658fae..f4dbb12c 100644 --- a/packages/iles/src/client/app/index.ts +++ b/packages/iles/src/client/app/index.ts @@ -1,4 +1,4 @@ -import { createApp as createClientApp, createSSRApp, ref } from 'vue' +import { createSSRApp as newApp, ref } from 'vue' import { createMemoryHistory, createRouter as createVueRouter, createWebHistory } from 'vue-router' import { createHead } from '@vueuse/head' @@ -16,8 +16,6 @@ import { defaultHead } from './head' import { resolveLayout } from './layout' import { resolveProps } from './props' -const newApp = import.meta.env.SSR ? createSSRApp : createClientApp - function createRouter (base: string | undefined, routerOptions: Partial) { if (base === '/') base = undefined diff --git a/packages/iles/src/node/build/render.ts b/packages/iles/src/node/build/render.ts index 762f4b4d..d714dc5d 100644 --- a/packages/iles/src/node/build/render.ts +++ b/packages/iles/src/node/build/render.ts @@ -47,12 +47,12 @@ export async function renderPage ( const { app, head } = await createApp({ routePath: route.path, ssrProps: route.ssrProps }) let content = await renderToString(app, { islandsByPath, renderers }) - // Remove comments from Vue renderer to allow plain text, RSS, or JSON output. - content = content.replace(commentsRegex, '') - // Skip HTML shell to allow Vue to render plain text, RSS, or JSON output. - if (!route.outputFilename.endsWith('.html')) + if (!route.outputFilename.endsWith('.html')) { + // Remove comments from Vue renderer to allow plain text, RSS, or JSON output. + content = content.replace(commentsRegex, '') return content + } const { headTags, htmlAttrs, bodyAttrs } = renderHeadToString(head)