]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor: use named export for compiled render function
authorEvan You <yyx990803@gmail.com>
Tue, 24 Dec 2019 15:51:26 +0000 (10:51 -0500)
committerEvan You <yyx990803@gmail.com>
Tue, 24 Dec 2019 16:04:44 +0000 (11:04 -0500)
packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap
packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap
packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap
packages/compiler-core/__tests__/scopeId.spec.ts
packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap
packages/compiler-core/__tests__/transforms/__snapshots__/vModel.spec.ts.snap
packages/compiler-core/src/codegen.ts
packages/compiler-sfc/__tests__/__snapshots__/templateTransformAssetUrl.spec.ts.snap
packages/compiler-sfc/__tests__/__snapshots__/templateTransformSrcset.spec.ts.snap
packages/compiler-sfc/__tests__/compileTemplate.spec.ts

index f599fcfa0b1f41e714adc9513115487d90824a4a..785d3be37e2c6b38f0ba92b710625a444c028d54 100644 (file)
@@ -14,7 +14,7 @@ return function render() {
 
 exports[`compiler: codegen CacheExpression 1`] = `
 "
-export default function render() {
+export function render() {
   const _ctx = this
   const _cache = _ctx.$cache
   return _cache[1] || (_cache[1] = foo)
@@ -23,7 +23,7 @@ export default function render() {
 
 exports[`compiler: codegen CacheExpression w/ isVNode: true 1`] = `
 "
-export default function render() {
+export function render() {
   const _ctx = this
   const _cache = _ctx.$cache
   return _cache[1] || (
@@ -167,7 +167,7 @@ return function render() {
 exports[`compiler: codegen module mode preamble 1`] = `
 "import { createVNode, resolveDirective } from \\"vue\\"
 
-export default function render() {
+export function render() {
   const _ctx = this
   return null
 }"
index e3e4c726c0ab024f11f14d37a5e3c3913d9444b2..55bb9f92114f3f5fa8dadd071bf39a77cdd5f9bc 100644 (file)
@@ -50,7 +50,7 @@ return function render() {
 exports[`compiler: integration tests module mode 1`] = `
 "import { toString, openBlock, createVNode, createBlock, createCommentVNode, Fragment, renderList, createTextVNode } from \\"vue\\"
 
-export default function render() {
+export function render() {
   const _ctx = this
   return (openBlock(), createBlock(\\"div\\", {
     id: \\"foo\\",
index ea08f272accecaa5b05e044637926dabde9bed84..d0fd955caa793a54a3041680fd19bb08fa2693e5 100644 (file)
@@ -9,7 +9,7 @@ const _hoisted_1 = createVNode(\\"div\\", null, \\"hello\\")
 const _hoisted_2 = createVNode(\\"div\\", null, \\"world\\")
 popScopeId()
 
-export default withId(function render() {
+export const render = withId(function render() {
   const _ctx = this
   return (openBlock(), createBlock(\\"div\\", null, [
     _hoisted_1,
@@ -22,7 +22,7 @@ exports[`scopeId compiler support should wrap default slot 1`] = `
 "import { createVNode, resolveComponent, createBlock, openBlock, withScopeId } from \\"vue\\"
 const withId = withScopeId(\\"test\\")
 
-export default withId(function render() {
+export const render = withId(function render() {
   const _ctx = this
   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\\"
 const withId = withScopeId(\\"test\\")
 
-export default withId(function render() {
+export const render = withId(function render() {
   const _ctx = this
   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\\"
 const withId = withScopeId(\\"test\\")
 
-export default withId(function render() {
+export const render = withId(function render() {
   const _ctx = this
   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\\"
 const withId = withScopeId(\\"test\\")
 
-export default withId(function render() {
+export const render = withId(function render() {
   const _ctx = this
   return (openBlock(), createBlock(\\"div\\"))
 })"
index 37cde9c2e55761ec7a4eefad83b553f30ca1914d..de645d17126c49e768f4282f7591d5d130b8aeda 100644 (file)
@@ -19,7 +19,7 @@ describe('scopeId compiler support', () => {
     })
     expect(ast.helpers).toContain(WITH_SCOPE_ID)
     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()
   })
 
index 5173080d2881ef4f495c333abacfc24724244915..bce5d8ed7a254a1a2e764cabda579e275b237963 100644 (file)
@@ -210,7 +210,7 @@ return function render() {
 exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist elements with cached handlers 1`] = `
 "import { createVNode, createBlock, openBlock } from \\"vue\\"
 
-export default function render() {
+export function render() {
   const _ctx = this
   const _cache = _ctx.$cache
   return (openBlock(), createBlock(\\"div\\", null, [
index 5dac514795cae3952d51cff8a811bb6ef3cb321c..18f9d54fe98414253c2172938613368e85bd0b65 100644 (file)
@@ -3,7 +3,7 @@
 exports[`compiler: transform v-model compound expression (with prefixIdentifiers) 1`] = `
 "import { createVNode, createBlock, openBlock } from \\"vue\\"
 
-export default function render() {
+export function render() {
   const _ctx = this
   return (openBlock(), createBlock(\\"input\\", {
     modelValue: _ctx.model[_ctx.index],
@@ -30,7 +30,7 @@ return function render() {
 exports[`compiler: transform v-model simple exprssion (with prefixIdentifiers) 1`] = `
 "import { createVNode, createBlock, openBlock } from \\"vue\\"
 
-export default function render() {
+export function render() {
   const _ctx = this
   return (openBlock(), createBlock(\\"input\\", {
     modelValue: _ctx.model,
@@ -72,7 +72,7 @@ return function render() {
 exports[`compiler: transform v-model with dynamic argument (with prefixIdentifiers) 1`] = `
 "import { createVNode, createBlock, openBlock } from \\"vue\\"
 
-export default function render() {
+export function render() {
   const _ctx = this
   return (openBlock(), createBlock(\\"input\\", {
     [_ctx.value]: _ctx.model,
index f46b332254c634d39809908b77f23d9c4d18b91a..d235263640fef51fb90719df6d567bcbf695ef73 100644 (file)
@@ -224,12 +224,12 @@ export function generate(
     }
     genHoists(ast.hoists, context)
     newline()
-    push(`export default `)
+    push(`export `)
   }
 
   // enter render function
   if (genScopeId) {
-    push(`withId(`)
+    push(`const render = withId(`)
   }
   push(`function render() {`)
   indent()
index 580a70b4f7903df227bf978fe451123a67838c81..d6d255caf55877a627c1fdbcb74173c0b2c1b3d8 100644 (file)
@@ -7,7 +7,7 @@ import _imports_0 from '@svg/file.svg'
 
 const _hoisted_1 = _imports_0 + '#fragment'
 
-export default function render() {
+export function render() {
   const _ctx = this
   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`] = `
 "import { createVNode, createBlock, openBlock } from \\"vue\\"
 
-export default function render() {
+export function render() {
   const _ctx = this
   return (openBlock(), createBlock(\\"use\\", { href: '' }))
 }"
@@ -28,7 +28,7 @@ import _imports_0 from './logo.png'
 import _imports_1 from 'fixtures/logo.png'
 
 
-export default function render() {
+export function render() {
   const _ctx = this
   return (openBlock(), createBlock(Fragment, null, [
     createVNode(\\"img\\", { src: _imports_0 }),
index 2ea6edbd6024f9688b5d63aa1519cba50c94cc24..78c4bffabfd72e41c7158e40d530b90eaf137381 100644 (file)
@@ -13,7 +13,7 @@ const _hoisted_5 = _imports_0 + '2x, ' + _imports_0
 const _hoisted_6 = _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
   return (openBlock(), createBlock(Fragment, null, [
     createVNode(\\"img\\", {
index 03a32ba0f66dea0b2af3d5ab7e434825115aabe6..fa86618b1869f11a150b27e7843f2b4bf32d5191 100644 (file)
@@ -9,7 +9,7 @@ test('should work', () => {
   expect(result.errors.length).toBe(0)
   expect(result.source).toBe(source)
   // should expose render fn
-  expect(result.code).toMatch(`export default function render()`)
+  expect(result.code).toMatch(`export function render()`)
 })
 
 test('preprocess pug', () => {