vite-plugin-vue icon indicating copy to clipboard operation
vite-plugin-vue copied to clipboard

Inconsistent behavior overriding standard object

Open silane opened this issue 9 months ago • 1 comments

Related plugins

Describe the bug

I am not exactly sure this is a bug of this plugin-in, sorry if this is not caused by this plugin-in.

Returning object of same name as standard object such as JSON or Date from setup function sometimes overrides standard object and sometimes not.

Although I cannot reproduce, I have an environment overriding always occur.

Reproduction

https://stackblitz.com/edit/vitejs-vite-4y7scdda?file=src%2Fcomponents%2FHelloWorld.vue

Steps to reproduce

  1. Open the reproduction URL
  2. Open src/components/HelloWorld.vue and look side by side with resulting page view. We see;
    • The first paragraph displays {{ JSON }}, and the JSON here is the object returned from setup function.
    • The second paragraph displays {{ JSON.toString() }}, and the JSON here is a standard object as can be seen from the resulting page shows [object JSON].

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vitejs/plugin-vue: ^5.2.1 => 5.2.1 
    vite: ^6.2.0 => 6.2.0

Used Package Manager

npm

Logs

No response

Validations

silane avatar Mar 05 '25 06:03 silane

It's an edge case. BTW, using JSON as a variable name is bad

edison1105 avatar Mar 12 '25 07:03 edison1105