question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Full `es2020` compatibility by default

See original GitHub issue

Description

I help maintain a library that requires es2020 syntax (e.g. import.meta.url and bignum support). We’d love to recommend Vite as a bundler that works “out of the box” with batteries included, but this doesn’t quite work because the default Vite target is es2019. Our goal is to make it as easy as possible to use our library with little programming experience, and we would really like to suggest a bundler that can be run directly without configuring anything.

The main README.md history says that es2020 used to be the target — back in 2020, actually!. This was revised in https://github.com/vitejs/vite/commit/d4160726501779417ef19f05cc621bf1a0302097 but I can’t find out the reasoning why. I was able to find some discussions and suggestions to update, such as https://github.com/vitejs/vite/pull/7279 , but they don’t seem to shed any light on this.

Now that it’s 2022 and ES2020 is well supported in browsers, would it be possible to revise the default? If not, could I ask for the reasoning for the current default, and what compatibility threshold might allow it to be revised in the future?

Thanks!

Suggested solution

Change the default target to es2020.

Alternative

No response

Additional context

No response

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

10reactions
lgarroncommented, Aug 2, 2022

Did you set optimizeDeps.esbuildOptions.target: 'es2020'? Or I think optimizeDeps.esbuildOptions.supported: { bigint: true } works too. We could bump up the defaults in Vite 4.

Yes, I’ve tried all three configs, separately and at the same time:

export default {
  build: { target: "es2020" },
  optimizeDeps: {
    esbuildOptions: { target: "es2020", supported: { bigint: true } },
  },
};

From playing around with this for an hour, it seems that Vite 3 has either undocumented behaviour and/or caching bugs, along with potentially different behaviour depending on whether a folder is passed on the commandline (compared to defaulting to the current folder). This all makes it exceedingly difficult to tell if I’m debugging properly. 😕

2reactions
justin0mcateercommented, Nov 8, 2022

It’s probably my just my ignorance, but I don’t understand why it is necessary (or makes any sense) to have to set the build target it five or six places.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ECMAScript 6 compatibility table
Feature name▻ Current browser 98% ES6 Trans‑ piler 25% Trace... Optimisation Optimisation Optimisation Optimi... §proper tail calls (tail call optimisation)▻ 0/2 0/2 0/2 §direct recursionc No...
Read more >
ES2020: Everything You Need to Know - martinmck.com
Learn about the latest ES2020 features. ... It's returning the full words rather than just the verbs! This is happening because match does...
Read more >
"es6" | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
Build Options - Vite
Browser compatibility target for the final bundle. The default value is a Vite special value, 'modules' , which targets browsers with native ES...
Read more >
Is Ionic framework's compatible with tsconfig target ES2020
To match with commons tsconfig, if I change target of ionic app to “ES2020” and module to 'commonjs', will there be any compatibility...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found