Skip to content

Compiled Vue 2.7 Script Setup Components crash when mounted in Vue 3 Compat #11164

Open
@jssullivan

Description

@jssullivan

Vue version

3.4.27 (happens in 3.3 as well) with both Vue Compat and Vue

Link to minimal reproduction

https://github.com/jssullivan/vue-3-not-running-compiled-script-setup

Steps to reproduce

1.Pull down the linked repository
2.Run pnpm i && pnpm dev
3. Open the app, Click the first button of a Compiled Vue 3 component working correctly
4. Click the second button, this is a Compiled Vue 2 component that uses the Composition Api with defineComponent
5. Click the last button, this is a Compiled Vue 2 component that uses script setup, see this crashes when trying to read the ref hello_vue_team

What is expected?

All three components render correctly

What is actually happening?

It crashes when reading the variable hello_vue_team defined in the script setup of the compiled Vue 2.7 component.

System Info

No response

Any additional comments?

Looking from a debugger it appears that the variable hello_vue_team is being correctly evaluated and attached to this. However _vm._self._setupProxy is undefined (which also happens for a non script setup component in that example).

Screenshot 2024-06-17 at 5 00 11 PM

This only caused a warning for the defineComponent compiled component, as the template as its reading directly from _vm

Screenshot 2024-06-17 at 5 00 30 PM

Naively in this minimum viable repro, it seems like thisProxy._self._setupProxy needs to be set to thisProxy inside renderComponentRoot. I can submit a PR with that change, but don't know if there are other impacts. I can alternatively add this to compatRender in @vue/compat.

Appreciate the assistance!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions