frandiox / vite-ssr

Use Vite for server side rendering in Node
MIT License
823 stars 91 forks source link

Error isFunction is not a function from defineComponent called from ClientOnly component. #204

Closed phlegx closed 1 year ago

phlegx commented 1 year ago

Hi!

I get this error in browser (client) console:

Uncaught TypeError: isFunction is not a function
    defineComponent runtime-core.esm-bundler.js:2252
    <anonymous> components.js:2

components.js:2 links to this code:

export const ClientOnly = defineComponent({ // <---------
    name: 'ClientOnly',
    setup(_, { slots }) {
        const show = ref(false);
        onMounted(() => {
            show.value = true;
        });
        return () => (show.value && slots.default ? slots.default() : null);
    },
});

Do I have miss configured vite?

phlegx commented 1 year ago

Hours of debugging, but without solution!

phlegx commented 1 year ago

Found a solution, but I dont know if it is the right one:

//vite.config.js
resolve: {
    alias: {
        vue: 'vue/dist/vue.runtime.esm-bundler.js',
    }
}

Discussion found on vitejs/vite/discussions/4158