fix(compiler-core): avoid generating useless createVNode helper (#2938)
close #2739
This commit is contained in:
@@ -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