fix(compiler-core): avoid generating useless createVNode helper (#2938)
close #2739
This commit is contained in:
@@ -207,7 +207,7 @@ describe('ssr: components', () => {
|
||||
</template>
|
||||
</foo>`).code
|
||||
).toMatchInlineSnapshot(`
|
||||
"const { resolveComponent: _resolveComponent, withCtx: _withCtx, renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode, createCommentVNode: _createCommentVNode } = require(\\"vue\\")
|
||||
"const { resolveComponent: _resolveComponent, withCtx: _withCtx, renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = require(\\"vue\\")
|
||||
const { ssrRenderComponent: _ssrRenderComponent, ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
|
||||
|
||||
return function ssrRender(_ctx, _push, _parent, _attrs) {
|
||||
|
||||
@@ -298,8 +298,17 @@ function subTransform(
|
||||
traverseNode(childRoot, childContext)
|
||||
// merge helpers/components/directives into parent context
|
||||
;(['helpers', 'components', 'directives'] as const).forEach(key => {
|
||||
childContext[key].forEach((value: any) => {
|
||||
;(parentContext[key] as any).add(value)
|
||||
childContext[key].forEach((value: any, helperKey: any) => {
|
||||
if (key === 'helpers') {
|
||||
const parentCount = parentContext.helpers.get(helperKey)
|
||||
if (parentCount === undefined) {
|
||||
parentContext.helpers.set(helperKey, value)
|
||||
} else {
|
||||
parentContext.helpers.set(helperKey, value + parentCount)
|
||||
}
|
||||
} else {
|
||||
;(parentContext[key] as any).add(value)
|
||||
}
|
||||
})
|
||||
})
|
||||
// imports/hoists are not merged because:
|
||||
|
||||
Reference in New Issue
Block a user