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

ERROR: Transforming const to the configured target environment #3335

Closed
eugeniosegala opened this issue Aug 23, 2023 · 2 comments
Closed

ERROR: Transforming const to the configured target environment #3335

eugeniosegala opened this issue Aug 23, 2023 · 2 comments

Comments

@eugeniosegala
Copy link

eugeniosegala commented Aug 23, 2023

Hello,

I'm experiencing an issue after upgrading ESBuild to version 0.18.20.

To be fully transparent, I'm using Vite 4.4.9 (I recently upgraded it by a few minors) and it looks like ESBuild was also upgraded as side-effect (just normal dependencies semver updates).

Every time I run the usual npm run build, I get:

error during build:
Error: Transform failed with 5 errors:
assets/header-!~{008}~.js:5:2: ERROR: Transforming const to the configured target environment ("chrome79", "edge114", "firefox114", "ios12", "safari9.1" + 3 overrides) is not supported yet
assets/header-!~{008}~.js:6:57: ERROR: Transforming const to the configured target environment ("chrome79", "edge114", "firefox114", "ios12", "safari9.1" + 3 overrides) is not supported yet
assets/header-!~{008}~.js:8:4: ERROR: Transforming const to the configured target environment ("chrome79", "edge114", "firefox114", "ios12", "safari9.1" + 3 overrides) is not supported yet
assets/header-!~{008}~.js:786:0: ERROR: Transforming const to the configured target environment ("chrome79", "edge114", "firefox114", "ios12", "safari9.1" + 3 overrides) is not supported yet
assets/header-!~{008}~.js:788:0: ERROR: Transforming const to the configured target environment ("chrome79", "edge114", "firefox114", "ios12", "safari9.1" + 3 overrides) is not supported yet

If I remove the target option from my Vite config file, the issue will disappear.

build: {
   outDir: "build",
   target: ["chrome79", "edge114", "firefox114", "ios12", "safari9.1"],
},

I'm aware that Vite uses ESBuild behind the scenes, and the target property is actually passed to it.

What could be causing the issue?

@hyrious
Copy link

hyrious commented Aug 23, 2023

Safari9.1 does not support ES6, so it can only use var etc. esbuild does not support lowering newer syntaxes to ES5.

@eugeniosegala
Copy link
Author

Hey @hyrious, thank you for your replay.

I think I know where the problem is, the list inside the target is generated using browserslist.

"browserslist": [
    "last 2 versions",
    "not dead",
    "safari >= 12",
    "ios_saf >= 12.1",
    "IE 11",
    "> 0.2%"
  ]

So I'm assuming there was a change in how the above was translated as it went from:

[ "chrome79", "edge111'" "firefox111", "ios12", "safari12" ]

to

[ 'chrome79', 'edge114', 'firefox114', 'ios12', 'safari9.1' ]

I basically reverted browserslist from 4.21.10 to 4.21.3 and the issue disappeared. I think there must a change in how the > 0.2% is calculated.

This issue can be closed as it's not related to ESBuild, I will reach out to the browserslist team, thanks!

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

No branches or pull requests

2 participants