core
core copied to clipboard
$toRef is not available unless $ref is also used
Vue version
3.2.37
Link to minimal reproduction
https://sfc.vuejs.org/#eNo9UNFqwkAQ/JXlKERBk/qapkKpBy1YFZtCH+4l6hojyd1xu9dSQv69l6T1bWdnbm9mWvFkbfzlUaQio6OrLAMhe7tU+mg0MVhnLMEjnPBcadz1aNIqDdBQmcIwAfCPxRTe2VW6nI2roC98zSlEb0hUlAiVhgIOhrnGaBB1SndTpZVOEljJtcwl5C8SNvIzh/XrRsJkvbifQr6Fvdztt6uPZxkP4tGZ157wFKzdOTxPtK/r6UN/bWSDvZ5isw/kEGIGUVhG4ccsGaOGkAEwNrYuGAMCyC6LZdsOr7suSwLq5TeJmImqscbxvClsfCWjQ3FDCeqPICVutSgRmu2xEhdmS2mS0PnY132l2LgyCVPsvOaqwRipmR+c+SZ04bAS/w2J7hcdw4ut
Steps to reproduce
- Write a new component that makes use of $toRef but does not use $ref
- You'll see the following error:
$toRef is not defined
What is expected?
Transform kicks in when $toRef is used.
What is actually happening?
Transformation of $toRef does not happen unless the same file uses $ref.
It does not seem to matter whether $ref is used in a commented line of code.
System Info
No response
Any additional comments?
Related discussion: https://github.com/vuejs/rfcs/discussions/369#discussioncomment-3204419
https://github.com/vuejs/core/blob/a95554d35c65e5bfd0bf9d1c5b908ae789345a6d/packages/reactivity-transform/src/reactivityTransform.ts#L29
easy to fix. PR welcome.
Maybe this issue has fixed
Maybe this issue has fixed
I don't think so, I've just tested against v3.2.38.
Unfortunately, Reactivity Transform has been dropped officially now, so I closed this issue/PR. If you want to keep using it, please consider the community version Vue Macros.
This PR has been merged to Vue Macros https://github.com/sxzz/unplugin-vue-macros/commit/8cc7b4cec38034540f7fecae0626965a9b1e7171.