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.

Modern JavaScript

See original GitHub issue

I think it is time to move to modern JavaScript in the source code.

IMPORTANT: This is not a proposal to drop support for some Browser!

JavaScript evolved a lot in the last years. This Repro is (except for esModules that are handled by rollup) written in es3 way. This is JavaScript of 1999.

good:

  • No transpiler needed
  • Runs in all Browsers

bad:

  • Bundle is bigger for all browsers with code they will never use
  • Development is more complex as you have to check if you are allowed to use specific features.

Proposal

Write source code in a modern syntax and transpile it down to differnet levels. I suggest transpiling for es3 and es2017. es2017 is supported by all evergreen Browsers (95% combined useage) and can be transpiled down as needed by the developer of a webpage.

We can provide more tragets as needed. The idea is not to add any breaking changes. So default entry file would still be the es3 version but developers can manualy change that. (Docs should be added how to to this in webpack, rollup, esbuild, …)

What changes in the source should happen

  1. Better build with transpile to es3
  2. Class Syntax to es6 classes (see #7614 - includes transpiling to es5)
  3. Instead of most Util functions use the native ones (transpiler handles the rest)
  4. Use modern syntax for example rest Arguments: (a, b, ...rest) => {/* ... */}

What about typescript?

I think typescript is great but I think we should do one step at a time so if this issue is resolved in a positive way we can talk about typescript. If the above is done you can rewrite all code to ts in no time.

See also #7591

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:34
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
mathe42commented, Sep 9, 2021

As @IvanSanchez said something dropping support for IE 10 this is not needed at all to go to es5 (just to clarify).

If you DROP: IE 7-8 (<0.05%) Frefox 2-3.6 (0.02%) Chrome 4-18 (0.1%) Safari 5-5.1 (<0.03%) Android Browser: 2.2-3 (0%)

= Drop support for 0.2% useage. We would have complete es5 with 2 small caveats (strict mode; parseInt not like spec with 0 at start).

And note that class syntax is es6.

see https://caniuse.com/es5

2reactions
Azbesciakcommented, May 15, 2022

@IvanSanchez

  1. Support only modern browsers => Support Chromium, Firefox, Safari but not IE, Lagacy Edge (non Chromium). Deprecating IE10 is a separate issue that can (and IMO should) be undertaken separately. Leaflet is considered stable because it works in old browsers still, so don’t assume fancy functionality and assume pre-chromium Edge is still a thing. In particular, do not assume WebGL.

So maybe it is time for leaflet 2.0? There is a versioning, also the modern web requires a lot more and has also wider capabilities - 3d rendering, webgl, more details. Nowdays apps are more interactive than just showing marker on the static map and let the user to click on it.

IMHO, if you want to handle the compability with IE10 or IE11, you can leave leaflet 1.x on it path, and apply only critical fixes, which would be not necessary - personaly I still use 1.5 because of some stuff which did not allow me to migrate at my time, and since then… I did not see any bigger reason to update.

And others would use new features, performance etc. Really, I though a couple times to migrate to some newer lib. Seriosuly, what is a percentage of IE10 users now? and why can’t they just ose the old version?

BTW does it not look strange to you that Volodymyr Agafonkin is using mapbox on this webgl demo? https://blog.mapbox.com/how-i-built-a-wind-map-with-webgl-b63022b5537f

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Modern JavaScript Tutorial
Modern JavaScript Tutorial: simple, but detailed explanations with examples and tasks, including: closures, document and events, object oriented programming ...
Read more >
Modern JavaScript - A guide to help you learn JavaScript ...
Syntax, data types, prototype-based programming, for loops, asynchronous and parallel execution, Node JS, npm, Deno, TypeScript, WebAssembly.
Read more >
Modern JavaScript Tutorial #1 - Intro & Setup - YouTube
Get the full Modern JavaScript (novice to ninja) course from Udemy.
Read more >
Learn Modern Javascript - ui.dev
Modern JavaScript. Lay the foundation for your JavaScript knowledge using the latest features. Get started today. Watering Illustration Modern JavaScript Course ...
Read more >
The Modern JavaScript Bootcamp - Udemy
The Modern JavaScript Bootcamp. Learn JavaScript by building real-world apps. Includes 3 real-world projects, 80 programming challenges, and ES6/ES7!
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