Page MenuHomePhabricator

Enable tree-shaking
Open, NormalPublic

Description

This task encompasses the work to enable the tree-shaking boogie-woogie necessary for Webpack to eliminate dead code:

  • Use imports and exports everywhere. require and module.exports do support this hip new dance.
  • Minimize side-effects in modules. For example, modules.js modifies the global mw object, mw.mobileFrontend, which is considered an impure side-effect.
  • Identify modules with side-effects in package.json. E.g.:
...,
"sideEffects": [
  "src/mobile.startup/modules.js"
],
...

https://webpack.js.org/guides/tree-shaking/

It would be useful to actually report dead functions and files so they can be removed from the codebase. Maybe these untested plugins can help?

Event Timeline

Niedzielski triaged this task as High priority.Aug 24 2018, 4:45 PM
Niedzielski created this task.
Jdlrobson lowered the priority of this task from High to Normal.Aug 27 2018, 11:52 PM
Jdlrobson added a subscriber: Jdlrobson.

Let's wait till we've ported the entirety of mobile.startup (and maybe other modules) before going down this route. I'll pull it in when I feel it's appropriate. Please feel free to bug me via dev-time session if you think differently.

Jdlrobson lowered the priority of this task from Normal to Low.Aug 30 2018, 1:32 AM

Change 463830 had a related patch set uploaded (by Niedzielski; owner: Stephen Niedzielski):
[mediawiki/extensions/MobileFrontend@master] Hygiene: inline util.noop

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

Change 463833 had a related patch set uploaded (by Niedzielski; owner: Stephen Niedzielski):
[mediawiki/extensions/MobileFrontend@master] Hygiene: eliminate Browser and util side-effects

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

Change 463830 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Hygiene: inline util.noop

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

Change 463833 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Hygiene: eliminate Browser and util side-effects

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

Niedzielski updated the task description. (Show Details)Feb 11 2019, 5:04 PM
Jdlrobson raised the priority of this task from Low to Normal.Mar 8 2019, 8:04 PM