Skip to content

(compiler-sfc): <script setup> - Import usage analyzer doesn't resolve dynamic arguments in non-inline mode #8537

@mattersj

Description

@mattersj

Vue version

3.3.4

Link to minimal reproduction

https://play.vuejs.org/#__DEV__eNqFUctuwjAQ/JWVe+BCbAluaahAfEAvvTU9hGSB0Pgh26GVUP69ayfQABW9RNqZ3ZnJ+MRWxvBjiyxlmSttbTw49K2BplC7Rc68y9lLrmpptPVwAotb6GBrtYQJnU1G1Bs6P43f183hssQFqlZy735X11qaCxuGEIDoTPQJyI8Gj9I0hUeaALJ48/Qe1Pl6XzfVR8QB4hBXotTdNmXhK6X9Hu35ZBivjjJx8WNTdg71TyuPArtGe1CFRFovY0YG4p4qhiw9eZ1iKI5C4HcsLgCxYDgFofjrsIBJ1J9MAzb8W0AH6YB3IeAgUmpFAudnWoyk0r+UCBwLPeeKkvUPmcjC8IPTihJGlXwgqJ201w0Y9RjmnO29Ny4VolXmc8dLLcWSOGFb5WuJSaXlcs5nfDYXVe38GOfoZLKx+suhJcecxYSDuCDwiDaxqCq0ocsHZje7V4Y33J1p8KQmO9b9AN3rF8I=

Steps to reproduce

Steps to reproduce the bug from scratch (repro already has this covered):

  1. Import an object/enum from another file.
  2. Try to use their keys as a source of dynamic attribute name or slot name in <script setup> component. Note that this enum/object is not supposed to be used anywhere else in the component except the mentioned place.
  3. Observe an error since our object/enum is not exposed to the template (you can also check the generated code and take a look at the final __returned__ variable).

What is expected?

This object/enum should be properly exposed to the template in the final __returned__ variable since it's already being used in the template.

What is actually happening?

An error like Cannot read properties of undefined (reading 'someProperty') because the variable we're trying to get access to is not exposed.

System Info

System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 87.78 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  Browsers:
    Chrome: 114.0.5735.106
    Firefox: 113.0.2
    Safari: 15.5
  npmPackages:
    vue: ^3.3.4 => 3.3.4

Any additional comments?

This is a regression from v3.2.0-beta.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    has PRA pull request has already been submitted to solve the issue🔩 p2-edge-case

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy