Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite wraps keys of objects in quotes when not necessary #18985

Closed
7 tasks done
floratmin opened this issue Dec 17, 2024 · 1 comment
Closed
7 tasks done

Vite wraps keys of objects in quotes when not necessary #18985

floratmin opened this issue Dec 17, 2024 · 1 comment

Comments

@floratmin
Copy link

Describe the bug

I am having this object:

const ꁈꄼሕᣎᠳ勞 = {
    ꁈꄼሕᣎᠳ勞: 'test ',
    ฆ理ꃝꋹᕠ礼: 'bar'
};

when I build it this becomes:

const r={"ꁈꄼሕᣎᠳ勞":"test ",ฆ理ꃝꋹᕠ礼:"bar"};

With rollup the quotes are not added.

Reproduction

https://stackblitz.com/edit/vitejs-vite-wa7pdnu4?file=dist%2Fassets%2Findex-D-qYHHrO.js

Steps to reproduce

npm run build

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:
    vite: ^6.0.3 => 6.0.3

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

It seems esbuild quotes (U+18CE).
ID_Start category can be used as an identifier for ES2015+. U+18CE is in the Other Letter category which is included in ID_Start category. But this character was added in Unicode 5.2.

ES5 uses Unicode 3.0 (evanw/esbuild#1599) and ES2015 use Unicode 5.1 and ES2016 uses Unicode 8.0.0. So that character can only be used as an identifier for ES2016+.

I guess esbuild quotes the character for compat and does it regardless of the target because it's not worth much.

Closing as this is not a bug in Vite. If it's important for you, I recommend opening an issue in esbuild.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants