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

Unexpected result when esbuild.transform is enabled with minifySyntax @0.14.40 #2270

Closed
yanm1ng opened this issue May 27, 2022 · 4 comments · Fixed by #2273
Closed

Unexpected result when esbuild.transform is enabled with minifySyntax @0.14.40 #2270

yanm1ng opened this issue May 27, 2022 · 4 comments · Fixed by #2273

Comments

@yanm1ng
Copy link

yanm1ng commented May 27, 2022

esbuild version 0.14.39

const esbuild = require('esbuild');

(async () => {
  const result = await esbuild.transform(`const a = { '-2': 'xxx' }`, {
    target: 'es6',
    minifySyntax: true,
  });
  console.log(result.code);
  // const a = { "-2": "xxx" };
})();

esbuild version 0.14.40

const esbuild = require('esbuild');

(async () => {
  const result = await esbuild.transform(`const a = { '-2': 'xxx' }`, {
    target: 'es6',
    minifySyntax: true,
  });
  console.log(result.code);
  // const a = { -2: "xxx" };
})();

{ -2: "xxx" } will cause browser errors.
image

@yanm1ng yanm1ng changed the title expected result is inconsistent when esbuild.transform is enabled with minifySyntax Unexpected result when esbuild.transform is enabled with minifySyntax May 27, 2022
@yanm1ng yanm1ng changed the title Unexpected result when esbuild.transform is enabled with minifySyntax Unexpected result when esbuild.transform is enabled with minifySyntax @0.14.40 May 27, 2022
@noonnightstorm
Copy link

same problem

@NickGeek
Copy link

NickGeek commented May 27, 2022

I've also ran into this minifying the following line:

t2.exports = { 2: "need dictionary", 1: "stream end", 0: "", "-1": "file error", "-2": "stream error", "-3": "data error", "-4": "insufficient memory", "-5": "buffer error", "-6": "incompatible version" };

@ZWkang
Copy link

ZWkang commented May 27, 2022

case in vite + esbuild + vue.js

const refref = ref({ '-1': 'somethings' })

turn to

const refref = ref({ -1: 'somethings' })

@evanw
Copy link
Owner

evanw commented May 27, 2022

Whoops, sorry about that. I will fix this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants