wip: template binding optimization

This commit is contained in:
Evan You
2020-07-10 22:12:25 -04:00
parent b51b79f5c4
commit b6cdd5621e
12 changed files with 81 additions and 30 deletions

View File

@@ -64,7 +64,8 @@ export interface CodegenResult {
map?: RawSourceMap
}
export interface CodegenContext extends Required<CodegenOptions> {
export interface CodegenContext
extends Omit<Required<CodegenOptions>, 'bindingMetadata'> {
source: string
code: string
line: number
@@ -204,16 +205,19 @@ export function generate(
}
// enter render function
const optimizeSources = options.bindingMetadata
? `, $props, $setup, $data, $options`
: ``
if (!ssr) {
if (genScopeId) {
push(`const render = ${PURE_ANNOTATION}_withId(`)
}
push(`function render(_ctx, _cache) {`)
push(`function render(_ctx, _cache${optimizeSources}) {`)
} else {
if (genScopeId) {
push(`const ssrRender = ${PURE_ANNOTATION}_withId(`)
}
push(`function ssrRender(_ctx, _push, _parent, _attrs) {`)
push(`function ssrRender(_ctx, _push, _parent, _attrs${optimizeSources}) {`)
}
indent()