refactor: use named export for compiled render function
This commit is contained in:
parent
4d20981eb0
commit
59c595c1e8
@ -14,7 +14,7 @@ return function render() {
|
|||||||
|
|
||||||
exports[`compiler: codegen CacheExpression 1`] = `
|
exports[`compiler: codegen CacheExpression 1`] = `
|
||||||
"
|
"
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
const _cache = _ctx.$cache
|
const _cache = _ctx.$cache
|
||||||
return _cache[1] || (_cache[1] = foo)
|
return _cache[1] || (_cache[1] = foo)
|
||||||
@ -23,7 +23,7 @@ export default function render() {
|
|||||||
|
|
||||||
exports[`compiler: codegen CacheExpression w/ isVNode: true 1`] = `
|
exports[`compiler: codegen CacheExpression w/ isVNode: true 1`] = `
|
||||||
"
|
"
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
const _cache = _ctx.$cache
|
const _cache = _ctx.$cache
|
||||||
return _cache[1] || (
|
return _cache[1] || (
|
||||||
@ -167,7 +167,7 @@ return function render() {
|
|||||||
exports[`compiler: codegen module mode preamble 1`] = `
|
exports[`compiler: codegen module mode preamble 1`] = `
|
||||||
"import { createVNode, resolveDirective } from \\"vue\\"
|
"import { createVNode, resolveDirective } from \\"vue\\"
|
||||||
|
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return null
|
return null
|
||||||
}"
|
}"
|
||||||
|
@ -50,7 +50,7 @@ return function render() {
|
|||||||
exports[`compiler: integration tests module mode 1`] = `
|
exports[`compiler: integration tests module mode 1`] = `
|
||||||
"import { toString, openBlock, createVNode, createBlock, createCommentVNode, Fragment, renderList, createTextVNode } from \\"vue\\"
|
"import { toString, openBlock, createVNode, createBlock, createCommentVNode, Fragment, renderList, createTextVNode } from \\"vue\\"
|
||||||
|
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return (openBlock(), createBlock(\\"div\\", {
|
return (openBlock(), createBlock(\\"div\\", {
|
||||||
id: \\"foo\\",
|
id: \\"foo\\",
|
||||||
|
@ -9,7 +9,7 @@ const _hoisted_1 = createVNode(\\"div\\", null, \\"hello\\")
|
|||||||
const _hoisted_2 = createVNode(\\"div\\", null, \\"world\\")
|
const _hoisted_2 = createVNode(\\"div\\", null, \\"world\\")
|
||||||
popScopeId()
|
popScopeId()
|
||||||
|
|
||||||
export default withId(function render() {
|
export const render = withId(function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return (openBlock(), createBlock(\\"div\\", null, [
|
return (openBlock(), createBlock(\\"div\\", null, [
|
||||||
_hoisted_1,
|
_hoisted_1,
|
||||||
@ -22,7 +22,7 @@ exports[`scopeId compiler support should wrap default slot 1`] = `
|
|||||||
"import { createVNode, resolveComponent, createBlock, openBlock, withScopeId } from \\"vue\\"
|
"import { createVNode, resolveComponent, createBlock, openBlock, withScopeId } from \\"vue\\"
|
||||||
const withId = withScopeId(\\"test\\")
|
const withId = withScopeId(\\"test\\")
|
||||||
|
|
||||||
export default withId(function render() {
|
export const render = withId(function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
const _component_Child = resolveComponent(\\"Child\\")
|
const _component_Child = resolveComponent(\\"Child\\")
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ exports[`scopeId compiler support should wrap dynamic slots 1`] = `
|
|||||||
"import { createVNode, resolveComponent, renderList, createSlots, createBlock, openBlock, withScopeId } from \\"vue\\"
|
"import { createVNode, resolveComponent, renderList, createSlots, createBlock, openBlock, withScopeId } from \\"vue\\"
|
||||||
const withId = withScopeId(\\"test\\")
|
const withId = withScopeId(\\"test\\")
|
||||||
|
|
||||||
export default withId(function render() {
|
export const render = withId(function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
const _component_Child = resolveComponent(\\"Child\\")
|
const _component_Child = resolveComponent(\\"Child\\")
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ exports[`scopeId compiler support should wrap named slots 1`] = `
|
|||||||
"import { toString, createTextVNode, createVNode, resolveComponent, createBlock, openBlock, withScopeId } from \\"vue\\"
|
"import { toString, createTextVNode, createVNode, resolveComponent, createBlock, openBlock, withScopeId } from \\"vue\\"
|
||||||
const withId = withScopeId(\\"test\\")
|
const withId = withScopeId(\\"test\\")
|
||||||
|
|
||||||
export default withId(function render() {
|
export const render = withId(function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
const _component_Child = resolveComponent(\\"Child\\")
|
const _component_Child = resolveComponent(\\"Child\\")
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ exports[`scopeId compiler support should wrap render function 1`] = `
|
|||||||
"import { createVNode, createBlock, openBlock, withScopeId } from \\"vue\\"
|
"import { createVNode, createBlock, openBlock, withScopeId } from \\"vue\\"
|
||||||
const withId = withScopeId(\\"test\\")
|
const withId = withScopeId(\\"test\\")
|
||||||
|
|
||||||
export default withId(function render() {
|
export const render = withId(function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return (openBlock(), createBlock(\\"div\\"))
|
return (openBlock(), createBlock(\\"div\\"))
|
||||||
})"
|
})"
|
||||||
|
@ -19,7 +19,7 @@ describe('scopeId compiler support', () => {
|
|||||||
})
|
})
|
||||||
expect(ast.helpers).toContain(WITH_SCOPE_ID)
|
expect(ast.helpers).toContain(WITH_SCOPE_ID)
|
||||||
expect(code).toMatch(`const withId = withScopeId("test")`)
|
expect(code).toMatch(`const withId = withScopeId("test")`)
|
||||||
expect(code).toMatch(`export default withId(function render() {`)
|
expect(code).toMatch(`export const render = withId(function render() {`)
|
||||||
expect(code).toMatchSnapshot()
|
expect(code).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ return function render() {
|
|||||||
exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist elements with cached handlers 1`] = `
|
exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist elements with cached handlers 1`] = `
|
||||||
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
||||||
|
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
const _cache = _ctx.$cache
|
const _cache = _ctx.$cache
|
||||||
return (openBlock(), createBlock(\\"div\\", null, [
|
return (openBlock(), createBlock(\\"div\\", null, [
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
exports[`compiler: transform v-model compound expression (with prefixIdentifiers) 1`] = `
|
exports[`compiler: transform v-model compound expression (with prefixIdentifiers) 1`] = `
|
||||||
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
||||||
|
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return (openBlock(), createBlock(\\"input\\", {
|
return (openBlock(), createBlock(\\"input\\", {
|
||||||
modelValue: _ctx.model[_ctx.index],
|
modelValue: _ctx.model[_ctx.index],
|
||||||
@ -30,7 +30,7 @@ return function render() {
|
|||||||
exports[`compiler: transform v-model simple exprssion (with prefixIdentifiers) 1`] = `
|
exports[`compiler: transform v-model simple exprssion (with prefixIdentifiers) 1`] = `
|
||||||
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
||||||
|
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return (openBlock(), createBlock(\\"input\\", {
|
return (openBlock(), createBlock(\\"input\\", {
|
||||||
modelValue: _ctx.model,
|
modelValue: _ctx.model,
|
||||||
@ -72,7 +72,7 @@ return function render() {
|
|||||||
exports[`compiler: transform v-model with dynamic argument (with prefixIdentifiers) 1`] = `
|
exports[`compiler: transform v-model with dynamic argument (with prefixIdentifiers) 1`] = `
|
||||||
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
||||||
|
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return (openBlock(), createBlock(\\"input\\", {
|
return (openBlock(), createBlock(\\"input\\", {
|
||||||
[_ctx.value]: _ctx.model,
|
[_ctx.value]: _ctx.model,
|
||||||
|
@ -224,12 +224,12 @@ export function generate(
|
|||||||
}
|
}
|
||||||
genHoists(ast.hoists, context)
|
genHoists(ast.hoists, context)
|
||||||
newline()
|
newline()
|
||||||
push(`export default `)
|
push(`export `)
|
||||||
}
|
}
|
||||||
|
|
||||||
// enter render function
|
// enter render function
|
||||||
if (genScopeId) {
|
if (genScopeId) {
|
||||||
push(`withId(`)
|
push(`const render = withId(`)
|
||||||
}
|
}
|
||||||
push(`function render() {`)
|
push(`function render() {`)
|
||||||
indent()
|
indent()
|
||||||
|
@ -7,7 +7,7 @@ import _imports_0 from '@svg/file.svg'
|
|||||||
|
|
||||||
const _hoisted_1 = _imports_0 + '#fragment'
|
const _hoisted_1 = _imports_0 + '#fragment'
|
||||||
|
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return (openBlock(), createBlock(\\"use\\", { href: _hoisted_1 }))
|
return (openBlock(), createBlock(\\"use\\", { href: _hoisted_1 }))
|
||||||
}"
|
}"
|
||||||
@ -16,7 +16,7 @@ export default function render() {
|
|||||||
exports[`compiler sfc: transform asset url support uri is empty 1`] = `
|
exports[`compiler sfc: transform asset url support uri is empty 1`] = `
|
||||||
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
"import { createVNode, createBlock, openBlock } from \\"vue\\"
|
||||||
|
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return (openBlock(), createBlock(\\"use\\", { href: '' }))
|
return (openBlock(), createBlock(\\"use\\", { href: '' }))
|
||||||
}"
|
}"
|
||||||
@ -28,7 +28,7 @@ import _imports_0 from './logo.png'
|
|||||||
import _imports_1 from 'fixtures/logo.png'
|
import _imports_1 from 'fixtures/logo.png'
|
||||||
|
|
||||||
|
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return (openBlock(), createBlock(Fragment, null, [
|
return (openBlock(), createBlock(Fragment, null, [
|
||||||
createVNode(\\"img\\", { src: _imports_0 }),
|
createVNode(\\"img\\", { src: _imports_0 }),
|
||||||
|
@ -13,7 +13,7 @@ const _hoisted_5 = _imports_0 + '2x, ' + _imports_0
|
|||||||
const _hoisted_6 = _imports_0 + '2x, ' + _imports_0 + '3x'
|
const _hoisted_6 = _imports_0 + '2x, ' + _imports_0 + '3x'
|
||||||
const _hoisted_7 = _imports_0 + ', ' + _imports_0 + '2x, ' + _imports_0 + '3x'
|
const _hoisted_7 = _imports_0 + ', ' + _imports_0 + '2x, ' + _imports_0 + '3x'
|
||||||
|
|
||||||
export default function render() {
|
export function render() {
|
||||||
const _ctx = this
|
const _ctx = this
|
||||||
return (openBlock(), createBlock(Fragment, null, [
|
return (openBlock(), createBlock(Fragment, null, [
|
||||||
createVNode(\\"img\\", {
|
createVNode(\\"img\\", {
|
||||||
|
@ -9,7 +9,7 @@ test('should work', () => {
|
|||||||
expect(result.errors.length).toBe(0)
|
expect(result.errors.length).toBe(0)
|
||||||
expect(result.source).toBe(source)
|
expect(result.source).toBe(source)
|
||||||
// should expose render fn
|
// should expose render fn
|
||||||
expect(result.code).toMatch(`export default function render()`)
|
expect(result.code).toMatch(`export function render()`)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('preprocess pug', () => {
|
test('preprocess pug', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user