Page MenuHomePhabricator

Simplify/modernise JavaScript files in IP Info extension {L}
Closed, ResolvedPublic

Description

Background

IP Info's JavaScript files (the files) are bundled in a ResourceLoader's package files module. We can leverage this to simplify/modernise those JavaScript files:

  • Using module.exports and require() so that we don't need to attach code to the global mw object; and
  • The files in a ResourceLoader package files module are delivered in their own closures, we can removing all IIFEs (Immediately Invoked Function Expressions) wrapping their contents. Ref T50886.

Further, we dropped the one-var rule from the Wikimedia's ESLint config in March (see https://github.com/wikimedia/eslint-config-wikimedia/issues/360 and https://wikimedia.slack.com/archives/C01CQ80JB6U/p1616012846006800 for additional discussion), which means that we can break up any big comma-separated var statements in the files too.

AC
  • All IIFEs wrapping the contents of JavaScript files are removed
  • The mw.IpInfo "namespace" (property) created in modules/ext.ipInfo/widget.js is deleted
  • IPInfoWidget is exported from modules/ext.ipInfo/widget.js
  • The */init.js files require the above to import IPInfoWidget
  • Break up big comma-separated var statements wherever possible

Event Timeline

ARamirez_WMF renamed this task from Simplify/modernise JavaScript files in IP Info extension to Simplify/modernise JavaScript files in IP Info extension {L}.Dec 14 2021, 5:07 PM

Decided to focus on task triage and let someone else take this

Change 752260 had a related patch set uploaded (by STran; author: STran):

[mediawiki/extensions/IPInfo@master] Refactor js files

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

Change 753009 had a related patch set uploaded (by STran; author: STran):

[mediawiki/extensions/IPInfo@master] Split up var statements

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

Change 752260 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] Refactor js files

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

Change 753009 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] Split up var statements

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