Page MenuHomePhabricator

Explore reducing Resource Loader modules further
Open, MediumPublic

Description

Translation is supported by Content/Section Translation. Surfacing the possibility to translate when it may be needed is convenient for multilingual users.

As more entry points are planned (T286641), we want to consider how to better organize their code to improve the situation with module bundling (T286645#7316780)

This ticket is focused on entry points (existing ones in Content Translation, and planned ones for Section Translation) but can include also other refactorings that can help in general.

Details

ProjectBranchLines +/-Subject
mediawiki/extensions/ContentTranslationmaster+2 -7
mediawiki/extensions/ContentTranslationmaster+2 -9
mediawiki/extensions/ContentTranslationmaster+0 -2
mediawiki/extensions/ContentTranslationmaster+26 -62
mediawiki/extensions/ContentTranslationmaster+91 -167
mediawiki/extensions/ContentTranslationmaster+0 -102
mediawiki/extensions/ContentTranslationmaster+1 -98
mediawiki/extensions/ContentTranslationmaster+13 -52
mediawiki/extensions/ContentTranslationmaster+15 -34
mediawiki/extensions/ContentTranslationmaster+62 -87
mediawiki/extensions/ContentTranslationmaster+55 -148
mediawiki/extensions/ContentTranslationmaster+0 -157
mediawiki/extensions/ContentTranslationmaster+38 -101
mediawiki/extensions/ContentTranslationmaster+0 -126
mediawiki/extensions/ContentTranslationmaster+8 -22
mediawiki/extensions/ContentTranslationmaster+0 -40
mediawiki/extensions/ContentTranslationmaster+0 -64
mediawiki/extensions/ContentTranslationmaster+8 -25
Show related patches Customize query in gerrit

Event Timeline

santhosh renamed this task from Explore how translation entry point code can be organized to improve module bundling to Explore reducing Resource Loader modules further.Sep 8 2021, 6:24 AM

Change 719451 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] Merge RL module for dismissable message widget with infobar

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

Change 719452 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] Remove unused RL module mw.cx.ui.Header.skin

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

Change 719453 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] Merge ve.ui.CXSurface and ve.ui.CXDesktopContext RL modules to ve.init.mw.CXTarget

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

Change 719460 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] Remove ext.cx.util RL module

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

Change 719453 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge ve.ui.CXSurface and ve.ui.CXDesktopContext RL modules to ve.init.mw.CXTarget

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

Change 719467 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] Remove mw.cx.tools.SearchTool ResourceLoader module

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

Change 719467 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Remove mw.cx.tools.SearchTool ResourceLoader module

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

Following RL modules removed so far

  1. mw.cx.tools.SearchTool
  2. ve.ui.CXSurface
  3. ve.ui.CXDesktopContext
  4. ext.cx.utils
  5. mw.cx.ui.Header.skin
  6. mw.cx.ui.MessageWidget

Change 719460 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Remove ext.cx.util RL module

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

Change 719451 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge RL module for dismissable message widget with infobar

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

Change 719452 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Remove unused RL module mw.cx.ui.Header.skin

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

DannyS712 added a subscriber: DannyS712.

Sorry, didn't see this task when I filed another one.
Copied from there:

A bunch of the ResourceLoader modules that are registered are only used in one place, as a dependency for another module. Since things aren't using package files yet, its fairly trivial to merge modules, just list the scripts/styles/messages/dependencies for both. The following modules can be merged:

Format is:
parent module
* dependency just used in the parent that can be merged into it

ext.cx.dashboard:
* ext.cx.feedback
* mw.cx.SourcePageSelector
* mw.cx.dashboard.lists
* ext.cx.widgets.translator

mw.cx.SourcePageSelector:
* mw.cx.SelectedSourcePage
* mw.cx.ui.PageSelectorWidget

mw.cx.SelectedSourcePage:
* ext.cx.tools.validator

mw.cx.dashboard.lists:
* ext.cx.progressbar

mw.cx.ui.TranslationView:
* mw.cx.dm.PageTitleModel
* mw.cx.tools.IssueTrackingTool
* mw.cx.ui.PageTitleWidget

ext.cx.stats:
* chart.js

ve.dm.CXLintableNode:
* mw.cx.dm.TranslationIssue

mw.cx.init:
* mw.cx.dm.WikiPage
* mw.cx.init.Translation
* mw.cx.MwApiRequestManager
* mw.cx.MachineTranslation
* ve.init.mw.CXTarget (only used by mw.cx.init.Translation and mw.cx.MwApiRequestManager, both are merged too)

v.init.mw.CXTarget:
* mw.cx.tools.TranslationToolFactory

mw.cx.tools.TranslationTool:
* mw.cx.ui.TranslationToolWidget

mw.cx.init.Translation:
* mw.cx.ui.TranslationView
* mw.cx.ui.Categories

mw.cx.visualEditor:
* mw.cx.visualEditor.sentence
* mw.cx.visualEditor.section
* mw.cx.visualEditor.link
* mw.cx.visualEditor.content
* mw.cx.visualEditor.mt
* mw.cx.visualEditor.publishSettings
* mw.cx.visualEditor.base (also used by the other mw.cx.visualEditor.* modules, but those are being merged too)

mw.cx.ui.Categories:
* mw.cx.ui.CategoryMultiselectWidget

Also, mw.cx.ui.PublishSettingsWidget and mw.cx.tools appear unused? And mw.cx.tools.TemplateTool is only used in mw.cx.tools.


I can send patches for these

Change 723205 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] Merge some widget ResourceLoader modules into their only users

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

Change 723369 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] Remove Rresource loader module mw.cx.ui.PublishSettingsWidget

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

Please keep ve.init.mw.CXTarget module as it is an important and logical grouping for VE integration of Content translation. It is possible to find it reusable in upcoming section translation work.

Also, mw.cx.ui.PublishSettingsWidget and mw.cx.tools appear unused? And mw.cx.tools.TemplateTool is only used in mw.cx.tools.

I removed mw.cx.ui.PublishSettingsWidget. mw.cx.tools can be removed I guess.

Change 723205 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge some widget ResourceLoader modules into their only users

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

Please keep ve.init.mw.CXTarget module as it is an important and logical grouping for VE integration of Content translation. It is possible to find it reusable in upcoming section translation work.

Also, mw.cx.ui.PublishSettingsWidget and mw.cx.tools appear unused? And mw.cx.tools.TemplateTool is only used in mw.cx.tools.

I removed mw.cx.ui.PublishSettingsWidget. mw.cx.tools can be removed I guess.

Okay, noted. I'll send patches for everything else in the next few days

Change 723350 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] Merge mw.cx.visualEditor.* modules into mw.cx.visualEditor

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

Change 723369 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Remove Resource loader module mw.cx.ui.PublishSettingsWidget

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

Change 723633 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] Merge two dependencies into mw.cx.init.Translation

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

Change 723350 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge mw.cx.visualEditor.* modules into mw.cx.visualEditor

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

Change 723633 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge two dependencies into mw.cx.init.Translation

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

Change 723784 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] Merge two more dependencies into mw.cx.init.Translation

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

Change 724107 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] Merge some dependencies into mw.cx.SourcePageSelector

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

Change 723784 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge two more dependencies into mw.cx.init.Translation

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

After https://gerrit.wikimedia.org/r/723350, https://gerrit.wikimedia.org/r/723633, https://gerrit.wikimedia.org/r/723784, and https://gerrit.wikimedia.org/r/724107 - found a few extra modules that could be merged

Format is:
parent module
* dependency just used in the parent that can be merged into it

ext.cx.dashboard:
* ext.cx.feedback
* mw.cx.SourcePageSelector
* mw.cx.dashboard.lists
* ext.cx.widgets.translator

ext.cx.stats:
* chart.js

ve.dm.CXLintableNode:
* mw.cx.dm.TranslationIssue

mw.cx.init:
* mw.cx.dm.WikiPage
* mw.cx.init.Translation
* mw.cx.MwApiRequestManager
* mw.cx.MachineTranslation

ve.init.mw.CXTarget:
* mw.cx.tools.TranslationToolFactory

Merge: ve.ce.CXLintableNode and ve.dm.CXLintableNode are only used together, merge into new ve.CXLintableNode ?

Remove, unused:
* mw.cx.tools
* mw.cx.tools.TemplateTool (once mw.cx.tools is removed)

After removals:
* mw.cx.tools.InstructionsTool only used by lazy loading via mw.loader.using in mw.cx.ui.ToolsColumn.js, part of mw.cx.init.Translation, should be merged into there and dropping lazy loading
* mw.cx.tools.TranslationTool only used by mw.cx.init.Translation

mw.cx.ui.FeatureDiscoveryWidget is only used by ext.cx.entrypoints.contributionsmenu via lazy loading, merge them instead

(In case I notice it later and wonder why its not listed, after the merges into mw.cx.init above, ve.init.mw.CXTarget could also be merged (only used by mw.cx.init.Translation and mw.cx.MwApiRequestManager, both are merged too), but per request above it shouldn't be)

Change 724107 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge some dependencies into mw.cx.SourcePageSelector

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

Change 724590 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ContentTranslation@master] Remove unused mw.cx.tools.TemplateTool module

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

Change 724565 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] Drop mw.cx.tools and mw.cx.tools.TemplateTool modules

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

Change 724786 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] Merge some dependencies into ext.cx.dashboard

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

Change 724590 abandoned by Santhosh:

[mediawiki/extensions/ContentTranslation@master] Remove unused mw.cx.tools.TemplateTool module

Reason:

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

Change 724565 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Drop mw.cx.tools and mw.cx.tools.TemplateTool modules

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

Change 724786 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge 4 dependencies into ext.cx.dashboard

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

Will send the rest of the patches later today

Current state:

Format is:
parent module
* dependency just used in the parent that can be merged into it

ext.cx.stats:
* chart.js

ve.dm.CXLintableNode:
* mw.cx.dm.TranslationIssue

mw.cx.init:
* mw.cx.dm.WikiPage
* mw.cx.init.Translation
* mw.cx.MwApiRequestManager
* mw.cx.MachineTranslation

ve.init.mw.CXTarget:
* mw.cx.tools.TranslationToolFactory

Merge: ve.ce.CXLintableNode and ve.dm.CXLintableNode are only used together, merge into new ve.CXLintableNode ?

After removals:
* mw.cx.tools.InstructionsTool only used by lazy loading via mw.loader.using in mw.cx.ui.ToolsColumn.js, part of mw.cx.init.Translation, should be merged into there and dropping lazy loading
* Actually incorrect, used by mw.cx.tools.InstructionsTool too: mw.cx.tools.TranslationTool only used by mw.cx.init.Translation

mw.cx.ui.FeatureDiscoveryWidget is only used by ext.cx.entrypoints.contributionsmenu via lazy loading, merge them instead

(In case I notice it later and wonder why its not listed, after the merges into mw.cx.init above, ve.init.mw.CXTarget could also be merged (only used by mw.cx.init.Translation and mw.cx.MwApiRequestManager, both are merged too), but per request above it shouldn't be)

Change 725275 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] Merge 4 dependencies into mw.cx.init

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

[image snipped for size]

CX related modules reduced from 71 to 56. Thanks @DannyS712 for all help.

Happy to help - I'm tracking a bunch of my work for reducing modules in various extensions at https://docs.google.com/spreadsheets/d/18LeZ_rHCaiyWiCn6s0CmTQfFe8lctw12BPPiBUV7G1M/edit#gid=1955059740 and thats not even covering the config variables that are being removed separately from the javascript code. Hopefully we can remove a bunch more this week too

Change 725275 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge 4 dependencies into mw.cx.init

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

Change 726605 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] mw.cx.init - remove duplicated dependency on ve.init.mw.CXTarget

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

Change 726946 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] Merge mw.cx.tools.TranslationToolFactory into ve.init.mw.CXTarget

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

State after https://gerrit.wikimedia.org/r/726946

Format is:
parent module
* dependency just used in the parent that can be merged into it

ext.cx.stats:
* chart.js

ve.dm.CXLintableNode:
* mw.cx.dm.TranslationIssue

Merge: ve.ce.CXLintableNode and ve.dm.CXLintableNode are only used together, merge into new ve.CXLintableNode ?

After removals:
* mw.cx.tools.InstructionsTool only used by lazy loading via mw.loader.using in mw.cx.ui.ToolsColumn.js, part of mw.cx.init.Translation, should be merged into there and dropping lazy loading

mw.cx.ui.FeatureDiscoveryWidget is only used by ext.cx.entrypoints.contributionsmenu via lazy loading, merge them instead

(In case I notice it later and wonder why its not listed, after the merges into mw.cx.init above, ve.init.mw.CXTarget could also be merged (only used by mw.cx.init.Translation and mw.cx.MwApiRequestManager, both are merged too), but per request above it shouldn't be)

Change 726605 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] mw.cx.init - remove duplicated dependencies

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

Change 726946 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge mw.cx.tools.TranslationToolFactory into ve.init.mw.CXTarget

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

Change 727496 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/ContentTranslation@master] Merge mw.cx.dm.TranslationIssue into ve.dm.CXLintableNode

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

State after https://gerrit.wikimedia.org/r/727496

Format is:
parent module
* dependency just used in the parent that can be merged into it

ext.cx.stats:
* chart.js

Merge: ve.ce.CXLintableNode and ve.dm.CXLintableNode are only used together, merge into new ve.CXLintableNode ?

mw.cx.ui.FeatureDiscoveryWidget is only used by ext.cx.entrypoints.contributionsmenu via lazy loading, merge them instead

(In case I notice it later and wonder why its not listed, after the merges into mw.cx.init above, ve.init.mw.CXTarget could also be merged (only used by mw.cx.init.Translation and mw.cx.MwApiRequestManager, both are merged too), but per request above it shouldn't be)

SpecialContentTranslation loads mw.cx.init and sometimes also ext.cx.wikibase.link, based on if WikibaseClient is installed and $wgContentTranslationTranslateInTarget is configured. I suggest merging the wikibase module, which is a single js file, into .init - the wikibase file can be controlled via a javascript variable added to the page, which would be checked  upon loading - the wikibase file starts by lazing-loading its dependencies, so we can put the check there. Neither module is loaded anywhere else.

Once T248912 is done, ext.cx.icons is only used as a dependency of ext.cx.entrypoints.contributionsmenu and can be merged.

Some modules only used in one place via lazy loading that I think can be merged, results in slightly higher load time on the initial view if not already in store, but on the other hand means you don't have to wait for it to load when its needed

mw.cx.init
* bundle ext.cx.translation.conflict, small bit of styles and JS for handling conflicts, js doesn't run on load but rather waits for a hook
* bundle mw.cx.ui.CaptchaDialog, small bit of styles and JS for showing captch, on load simply defines mw.cx.ui.CaptchaDialog
* bundle mw.cx.ui.LoginDialog, small bit of JS for handling login
* bundle mw.cx.tools.InstructionsTool, loaded by mw.cx.ui.ToolsColumn.prototype.init at run time so its always going to be needed from my understanding?
	This would allow merging mw.cx.tools.TranslationTool, only used as a dependency of mw.cx.tools.InstructionsTool and mw.cx.init

Also:

The mw.cx.ui module does the following
* load ext.cx.model as a dependency
* load oojs-ui as a dependency
* run ui/mw.cx.ui.js, which sets mw.cx.ui to be { mixin: {} }, and initializes mw.cx.widgets to be an empty object if not already set

I propose moving the js initializations into ext.cx.model, which sets of mw.cx generally, we can then switch modules to instead depend on the base module and oojs-ui directly, allowing removal of mw.cx.ui. Should be done after the mw.cx.init merges probably (though the moving of the js can happen before)

The mw.cx.dm does similarly
* load ext.cx.model and oojs-ui as dependencies
* run dm/mw.cx.dm.js which just sets mw.cx.dm = {};

We should do the same merges as above

Also, instead of having mw.cx.externalmessages created in a hook handler to add extra messages to mw.cx.ui.CaptchaDialog, the only place they are used, we should just create that module that uses them in the hook handler (after above it will be merged into mw.cx.init)

Change 727496 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Merge mw.cx.dm.TranslationIssue into ve.dm.CXLintableNode

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