vite-plugin-vue
vite-plugin-vue copied to clipboard
Inconsistent behavior overriding standard object
Related plugins
-
[x] plugin-vue
-
[ ] plugin-vue-jsx
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
- Open the reproduction URL
- Open
src/components/HelloWorld.vueand look side by side with resulting page view. We see;- The first paragraph displays
{{ JSON }}, and theJSONhere is the object returned fromsetupfunction. - The second paragraph displays
{{ JSON.toString() }}, and theJSONhere is a standard object as can be seen from the resulting page shows[object JSON].
- The first paragraph displays
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
- [x] Follow our Code of Conduct
- [x] Read the Contributing Guidelines.
- [x] Read the docs.
- [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [x] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- [x] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [x] The provided reproduction is a minimal reproducible example of the bug.
It's an edge case. BTW, using JSON as a variable name is bad