diff --git a/package.json b/package.json index ce186ab31..e742eebf9 100644 --- a/package.json +++ b/package.json @@ -65,10 +65,14 @@ "vuex": "4.1.0" }, "peerDependencies": { + "@vue/compiler-dom": "^3.0.1", "@vue/server-renderer": "^3.0.1", "vue": "^3.0.1" }, "peerDependenciesMeta": { + "@vue/compiler-dom": { + "optional": true + }, "@vue/server-renderer": { "optional": true } diff --git a/src/renderToString.ts b/src/renderToString.ts index 0e666e8b9..1d770d734 100644 --- a/src/renderToString.ts +++ b/src/renderToString.ts @@ -1,8 +1,8 @@ -import { renderToString as baseRenderToString } from '@vue/server-renderer' import { DefineComponent } from 'vue' import { createInstance } from './createInstance' import { ComponentMountingOptions } from './mount' import { RenderMountingOptions } from './types' +import { requireVueServerRenderer } from './utils/requireOptionalPeer' export function renderToString< T, @@ -22,6 +22,8 @@ export function renderToString< ): Promise export function renderToString(component: any, options?: any): Promise { + const { renderToString: baseRenderToString } = requireVueServerRenderer() + if (options?.attachTo) { console.warn('attachTo option is not available for renderToString') } diff --git a/src/utils/compileSlots.ts b/src/utils/compileSlots.ts index fd06a934b..92c75e0a5 100644 --- a/src/utils/compileSlots.ts +++ b/src/utils/compileSlots.ts @@ -1,7 +1,9 @@ -import { compile } from '@vue/compiler-dom' import * as vue from 'vue' +import { requireVueCompilerDom } from './requireOptionalPeer' export function processSlot(source = '', Vue = vue) { + const { compile } = requireVueCompilerDom() + let template = source.trim() const hasWrappingTemplate = template && template.startsWith('