close
Page MenuHomePhabricator

Raise Grade A JavaScript requirement from ES2017 to ES2019 (ECMAScript 10)
Closed, ResolvedPublic

Description

T395347: Raise Grade A JavaScript requirement from ES2017 to ES2018 (ECMAScript 9) | T429706: Raise Grade A JavaScript requirement from ES2019 to ES2020 (ECMAScript 11)

What

This ticket is to raise the Grade A requirement for the Modern JS layer from ES2018 to the next milestone ES2019 (ECMAScript 10).

Why

This will allow MediaWiki JavaScript code to use the following syntax, internal functions, and other features, improving the developer experience:

  • ES2019
    • string trimming: String.trimStart()/String.trimEnd()
    • Object.fromEntries
    • Optional catch Binding
    • Array.flat() and flatMap()
Blockers
Todo

Once unblocked: (see old ticket T395347 for patch examples)

  1. browserslist-config-wikimedia: Update modern.json reflect any decided change to the Compatibility policy (skip if Grade A was unchanged)
  2. eslint-config-wikimedia:
  3. ResourceLoader:
    • update startup.js to raise feature tests requirement to ES2019
    • update Peast calls in Module::validateScriptFile(), maintenance/benchmarks/benchmarkJsValidate.php, and bump USERJSPARSE_CACHE_VERSION
  4. CodeMirror: update JavaScriptValidator to allow ES2019
  5. Documentation:

Event Timeline

(I created this because I want to reference it in a comment for replacing .replace( /^\s+/, '' ); with .trimStart().)

Krinkle renamed this task from Raise Grade A JavaScript requirement from ES2018 (ES9) to ES2019 (ES10) to Raise Grade A JavaScript requirement from ES2018 to ES2019 (ECMAScript 10).May 28 2026, 2:44 PM
Krinkle updated the task description. (Show Details)

I proposed at T395347#12037702 that we go from the ES2017 requirement we have today, directly to requiring ES2019. Two in one.

In a nut shell, this is because browsers don't implement and ship features from a given spec all at the same time. And, they can also land out of order. This creates a bit of an uneven distribution where some specs have one or two straggling browsers that, once they catch up to that one feature, the next spec has already already landed in that same browser by then. This means some years we can't move much, but to compensate, we can then move two at once in other years. This year is one of those years.

The only change in Grade A requirements for ES2018 at T395347 is raising Safari 11 to Safari 12. And that automatically takes care of ES2019 in this task as well.

Feature/BrowserChromeEdgeFirefoxSafariiOSAndroid
ES2019 Optional catch bindingChrome 66-----
ES2019 String trimStart() and trimEnd()Chrome 66-----
ES2019 Object.fromEntriesChrome 73-Firefox 63Safari 12iOS 12-
ES2019 Array.flat() and flatMap()Chrome 69-Firefox 62Safari 12iOS 12-

[…] These are the differences in browser support based on MDN data via caniuse.com (we'll confirm this later in BrowserStack when we review and verify the proposed startup.js patch, for planning purposes we can start by assuming that MDN is correct). Cells with a dash represent no change (minimum version is less then or equal to the current feature test in startup.js). Non-empty cells represent a raising of the Modern requirements (meaning that a Grade C browser goes from receiving Modern to receiving Basic). Bolded non-empty cells represent dropping support from Grade A.

Feature/BrowserChromeEdgeFirefoxSafariiOSAndroid
Grade A todayChrome 109 (2023)Edge 109 (2023)Firefox 109 (2023)Safari 11.1 (2018)iOS 11.3 (2018)Android 6 (2015) / Chrome 106 (2022)
Modern today (startup.js)Chrome 63Edge 79Firefox 58Safari 11.1iOS 11.2Android 5 (2014) / Chrome 95 (2021)
ES2018 for await---Safari 12iOS 12-
ES2018 async generators---Safari 12iOS 12-
ES2018 object spread------
ES2018 regexp dotAll--Firefox 78---
ES2018 named capture groupsChrome 64-Firefox 79-iOS 11.3-
ES2018 Unicode character classChrome 64-Firefox 78-iOS 11.3-

[…]

Krinkle triaged this task as Medium priority.

Change #1316985 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] ResourceLoader: Raise startup.js compatibility check to ES2019

https://gerrit.wikimedia.org/r/1316985

Change #1316987 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/extensions/CodeMirror@master] JavaScriptValidator: Raise allowance to ES2019

https://gerrit.wikimedia.org/r/1316987

Krinkle updated the task description. (Show Details)

Change #1316987 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] JavaScriptValidator: Raise allowance to ES2019

https://gerrit.wikimedia.org/r/1316987

Change #1316985 merged by jenkins-bot:

[mediawiki/core@master] ResourceLoader: Raise startup.js compatibility check to ES2019

https://gerrit.wikimedia.org/r/1316985

Krinkle renamed this task from Raise Grade A JavaScript requirement from ES2018 to ES2019 (ECMAScript 10) to Raise Grade A JavaScript requirement from ES2017 to ES2019 (ECMAScript 10).Mon, Aug 3, 2:43 PM
Krinkle updated the task description. (Show Details)

This shipped in wmf.14 (i.e. this week). We ideally should have announced it last week, but oh well.

I added the following to https://meta.wikimedia.org/wiki/Tech/News/2026/33:

Gadgets and scripts on Wikimedia wikis may now use ES2018 features and ES2019 features in JavaScript code. Previously, the platform only allowed up to ES2017. MediaWiki validates the source code to protect functionality from syntax errors and to ensure scripts are valid in all supported browsers.

Related previous announcements:

From this week, Wikimedia wikis will allow ES2017 features in JavaScript code for official code, gadgets, and user scripts. The most visible feature of ES2017 is async/await syntax, allowing for easier-to-read code. Until this week, the platform only allowed up to ES2016, and a few months before that, up to ES2015.

Gadgets and personal user scripts may now use JavaScript syntax introduced in ES6 (also known as "ES2015") and ES7 ("ES2016"). MediaWiki validates the source code to protect other site functionality from syntax errors, and to ensure scripts are valid in all supported browsers.

I left out mention of notable features this time, because the this year we don't have any that I think are well-known or recognisable to most Tech News subscribers. This information is linked to the "ES2018" and "ES2019" words instead.

Like last year, I left out mention of affected browsers because:

  • the affected browsers (iOS 11 and Safari 11) continue to receive Basic support. This change only affects interactive features that are involve Modern JavaScript. This means readers are unaffected and there is no need to pass on a message to wider communities.
  • the affected iOS device (2013 iPhone) is compatible with iOS 12, and continues to be supported with Modern JS if they upgrade,
  • the only affected Mac devices (2007-2008 models) make up less than <0.1% in their combined Safari 11 usage, and those Mac devices continue to be supported with Modern JS through Firefox or Chrome.

This is so narrow that it gives undue weight to highlight directly. The linked supported browsers does provide this information to anyone curious or in need of guideance. For example it says iPhone 5s (2013) must use iOS 12, and OS X 10.11 must use Firefox or Chrome instead of Safari.

I believe this is now done, not sure why it wasn't closed along with T395347.

I left it open because it was the primary link in the Tech News announcement last week. Now that the week has passed, and no comments were left here, it can be resolved indeed. Thanks.