fix(compiler-ssr): avoid unnecessary withCtx import
This commit is contained in:
parent
a0e2c12874
commit
08b4e8815d
@ -3,7 +3,7 @@ import { compile } from '../src'
|
|||||||
describe('ssr: components', () => {
|
describe('ssr: components', () => {
|
||||||
test('basic', () => {
|
test('basic', () => {
|
||||||
expect(compile(`<foo id="a" :prop="b" />`).code).toMatchInlineSnapshot(`
|
expect(compile(`<foo id="a" :prop="b" />`).code).toMatchInlineSnapshot(`
|
||||||
"const { resolveComponent: _resolveComponent, withCtx: _withCtx } = require(\\"vue\\")
|
"const { resolveComponent: _resolveComponent } = require(\\"vue\\")
|
||||||
const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
|
const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
|
||||||
|
|
||||||
return function ssrRender(_ctx, _push, _parent) {
|
return function ssrRender(_ctx, _push, _parent) {
|
||||||
@ -20,7 +20,7 @@ describe('ssr: components', () => {
|
|||||||
test('dynamic component', () => {
|
test('dynamic component', () => {
|
||||||
expect(compile(`<component is="foo" prop="b" />`).code)
|
expect(compile(`<component is="foo" prop="b" />`).code)
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"const { resolveDynamicComponent: _resolveDynamicComponent, withCtx: _withCtx } = require(\\"vue\\")
|
"const { resolveDynamicComponent: _resolveDynamicComponent } = require(\\"vue\\")
|
||||||
const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
|
const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
|
||||||
|
|
||||||
return function ssrRender(_ctx, _push, _parent) {
|
return function ssrRender(_ctx, _push, _parent) {
|
||||||
@ -30,7 +30,7 @@ describe('ssr: components', () => {
|
|||||||
|
|
||||||
expect(compile(`<component :is="foo" prop="b" />`).code)
|
expect(compile(`<component :is="foo" prop="b" />`).code)
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"const { resolveDynamicComponent: _resolveDynamicComponent, withCtx: _withCtx } = require(\\"vue\\")
|
"const { resolveDynamicComponent: _resolveDynamicComponent } = require(\\"vue\\")
|
||||||
const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
|
const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
|
||||||
|
|
||||||
return function ssrRender(_ctx, _push, _parent) {
|
return function ssrRender(_ctx, _push, _parent) {
|
||||||
@ -285,7 +285,7 @@ describe('ssr: components', () => {
|
|||||||
|
|
||||||
expect(compile(`<keep-alive><foo/></keep-alive>`).code)
|
expect(compile(`<keep-alive><foo/></keep-alive>`).code)
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"const { resolveComponent: _resolveComponent, withCtx: _withCtx } = require(\\"vue\\")
|
"const { resolveComponent: _resolveComponent } = require(\\"vue\\")
|
||||||
const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
|
const { ssrRenderComponent: _ssrRenderComponent } = require(\\"@vue/server-renderer\\")
|
||||||
|
|
||||||
return function ssrRender(_ctx, _push, _parent) {
|
return function ssrRender(_ctx, _push, _parent) {
|
||||||
|
@ -96,10 +96,12 @@ export const ssrTransformComponent: NodeTransform = (node, context) => {
|
|||||||
// Using the cloned node, build the normal VNode-based branches (for
|
// Using the cloned node, build the normal VNode-based branches (for
|
||||||
// fallback in case the child is render-fn based). Store them in an array
|
// fallback in case the child is render-fn based). Store them in an array
|
||||||
// for later use.
|
// for later use.
|
||||||
|
if (clonedNode.children.length) {
|
||||||
buildSlots(clonedNode, context, (props, children) => {
|
buildSlots(clonedNode, context, (props, children) => {
|
||||||
vnodeBranches.push(createVNodeSlotBranch(props, children, context))
|
vnodeBranches.push(createVNodeSlotBranch(props, children, context))
|
||||||
return createFunctionExpression(undefined)
|
return createFunctionExpression(undefined)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const props =
|
const props =
|
||||||
node.props.length > 0
|
node.props.length > 0
|
||||||
|
Loading…
Reference in New Issue
Block a user