phoenix-ru / fervid

All-in-One Vue compiler written in Rust
https://phoenix-ru.github.io/fervid/
Apache License 2.0
371 stars 9 forks source link

pure expression root nodes cannot be compiled #11

Closed leookun closed 8 months ago

leookun commented 8 months ago
<template>
   {{ 1+1 }}
</template>

<script setup>
import { ref } from 'vue'

const name = ref('fervid')
</script>
leookun commented 8 months ago

https://play.vuejs.org/#eNp9kL1OwzAUhV/lyktAVEFVt6ogAeoAAyBg9BIlN8HFf/JPiRT53bl21NKh6pac8/nosyf2YG29j8jWbBNQWdkEvOcaAKYJljdLSInrze1JRb++dcIG8BiipUQoa1yACRz2kKB3RkFFm1WGW6N9AN0ohLsMXFU9ur3oquu8Oy/RBluw4IntxVDvvNHkM2UNzlqjrJDo3mwQtMXZGkqTu0ZK8/tSsuAiLg55+43tz5l858eccfbu0JMGcnbsQuMGDHO9/XzFkb6PpTJdlERfKD/QGxmz44w9Rt2R9glXbJ/LYwk9fPntGFD7w6WyaCZT4TmjB3y6cPV/3VW9Kue4Tiz9AXzCmYs=

phoenix-ru commented 8 months ago

Thanks for your report. It happens because everything except ElementNode's is optimized away in the root. I'll fix this behaviour

phoenix-ru commented 8 months ago

Should be fixed now. Playground now produces as expected:

import { ref } from 'vue';
import { toDisplayString as _toDisplayString } from "vue";
export default {
    setup () {
        const name = ref('fervid');
        return (_ctx, _cache)=>_toDisplayString(1 + 1);
    }
};