Skip to content

Commit

Permalink
fix: process render function, exported as default (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x009922 authored May 9, 2021
1 parent 76dfcad commit 9cd1062
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
12 changes: 12 additions & 0 deletions e2e/__projects__/basic/components/FunctionalRenderFn.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
import { h } from 'vue'
export default () =>
h(
'div',
{
id: 'functional-render-fn'
},
'Nyan'
)
</script>
9 changes: 9 additions & 0 deletions e2e/__projects__/basic/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import NoScript from './components/NoScript.vue'
import PugRelative from './components/PugRelativeExtends.vue'
import { randomExport } from './components/NamedExport.vue'
import ScriptSetup from './components/ScriptSetup.vue'
import FunctionalRenderFn from './components/FunctionalRenderFn.vue'

// TODO: JSX for Vue 3? TSX?
import Jsx from './components/Jsx.vue'
Expand Down Expand Up @@ -179,3 +180,11 @@ xtest('processes .vue file using jsx', () => {
mount(Jsx)
expect(document.querySelector('#jsx')).toBeTruthy()
})

test('processes functional component exported as function', () => {
mount(FunctionalRenderFn)

const elem = document.querySelector('#functional-render-fn')
expect(elem).toBeTruthy()
expect(elem.innerHTML).toBe('Nyan')
})
2 changes: 1 addition & 1 deletion lib/generate-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function generateCode(
if (tempOutput.includes('exports.render = render;')) {
node.add(';exports.default = {...exports.default, render};')
} else {
node.add(';exports.default = {...exports.default};')
// node.add(';exports.default = {...exports.default};')
}

return node.toStringWithSourceMap({ file: filename })
Expand Down

0 comments on commit 9cd1062

Please sign in to comment.